Note that there are some explanatory texts on larger screens.

plurals
  1. POGeneric vs. specific element styles - for maintainability
    primarykey
    data
    text
    <p>Consider the following three scenarios...</p> <p><strong>Scenario A</strong></p> <pre><code>@import "reset.css"; /* ... */ p {margin:1em 0;} /* ... */ p#copyright {margin:0; padding:10px;} </code></pre> <p>In Scenario A, a <em>generic</em> rule is applied to all <code>&lt;p&gt;</code> elements that gives it top and bottom margins, so that the paragraphs are properly spaced when used in the HTML. But, by doing so, this causes cases where a <code>&lt;p&gt;</code> element now needs its generic margins removed for decorative purposes, e.g. the Copyright at the foot of the document must have no margins.</p> <p><strong>Scenario B</strong></p> <pre><code>@import "reset.css"; /* ... */ div.content_body p, div.sidebar_body p {margin:1em 0;} /* ... */ p#copyright {padding:10px;} </code></pre> <p>In Scenario B, it is assumed that <code>&lt;p&gt;</code> elements don't need top and bottom margins unless <em>explicitly defined</em>. Here the Content and Sidebar elements will need well-spaced paragraphs</p> <p><strong>Scenario C</strong></p> <pre><code>@import "reset.css"; /* ... */ p.spaced {margin:1em 0;} /* ... */ p#copyright {padding:10px;} </code></pre> <p>In Scenario C, only <code>&lt;p&gt;</code> elements with a class <code>spaced</code> will have top and bottom margins applied.</p> <p><strong>Questions:</strong></p> <p>Which is the better scenario to use, and more importantly why? What impact does each scenario have on:</p> <ul> <li>browser CSS performance</li> <li>CSS weight and maintainability</li> <li>the proliferation of UI defects</li> </ul> <p>If you had to add a new widget that needed flowing paragraphs, which scenario would be better for you?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload