Warren Shea

Warren Shea’s Notes for CSS (and SASS)

v20221213

Box Model

Hex w/ Alpha Transparency

Performance

Qualified Selectors (selectors prepended by an element)

Avoid these. They are slower, increase specificity and can’t be used for different elements

ul.list {}

Sometimes qualified selectors make a classname more semantic, but a better alternative is quasi-qualified selectors

/*ul*/.list {}

Specificity

Inline styles - Example: <h1 style="color: pink;">
IDs - Example: #navbar
Classes, pseudo-classes, attribute selectors - Example: .test, :hover, [href]
Elements and pseudo-elements - Example: h1, :before

How to Calculate Specificity?

Start at 0, add 100 for each ID value, add 10 for each class value (or pseudo-class or attribute selector), add 1 for each element selector or pseudo-element.
There is one exception to this rule: if you use the !important rule, it will even override inline styles!


Flexbox (CSS Flexible Box Layout Module)

Resources


CSS Grid

Resources


Useful Chrome Extensions

Stylus

Style configuration for noticing inconsistencies

* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
* * * * * * * { background-color: rgba(255,0,0,.2); }
* * * * * * * * { background-color: rgba(0,255,0,.2); }
* * * * * * * * * { background-color: rgba(0,0,255,.2); }

OR adding via the console:

let module_ui = document.createElement("style");
module_ui.type = 'text/css';
module_ui.setAttribute("data-id","glitch-id-element");

let module_ui_content = `
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
* * * * * * * { background-color: rgba(255,0,0,.2); }
* * * * * * * * { background-color: rgba(0,255,0,.2); }
* * * * * * * * * { background-color: rgba(0,0,255,.2); }`;
module_ui.appendChild(document.createTextNode(module_ui_content));
document.getElementsByTagName("head")[0].appendChild(module_ui);