The proposed scheme provides a simple mapping between HTML elements and presentation hints. – Håkon Lie
Inline with HTML <button style=“ background: rebeccapurple; color: white; font: inherit; padding: 0 1em;”>…</button>
<button style=“background: rebeccapurple; … ”>…</button><button style=“background: rebeccapurple; … ”>…</button><button style=“background: rebeccapurple; … ”>…</button><button style=“background: rebeccapurple; … ”>…</button><button style=“background: rebeccapurple; … ”>…</button><button style=“background: rebeccapurple; … ”>…</button>
We Can Combine Them #send > button.action[type=“submit”] {…} <form id=“send”> <button class=“action” type=“submit”>…</button></form>
We Can Stack Them button {…}.action {…[type=“submit”] {…}#send {…} <button id=“send” class=“action” type=“submit”>…</button>
button { background: gray; }.action { background: darkblue; }[type=“submit”] { background: darkgreen; background: var(--submit); }#send { background: maroon; } <button style=“background: darkviolet;” id=“send” class=“action” type=“submit”>…</button>
filtering -> declared values? cascading -> cascaded value? defaulting -> specified value resolving -> computed value formatting -> used value? constraining -> actual value?
Where We Have Control button { background: gray; }.action { background: darkblue; }[type=“submit”] { background: darkgreen; background: var(--submit); }#send { background: maroon; }
1000 – Inline styles 100 – Unique IDs 10 – Reusable classes & attributes 1 – Element types 0 – Universal * /* 1 + 10 + 10 + 0 == 21 */button.action[type=“submit”] * { … }
By That Logic… /* 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 = 100 */.class.class.class.class.class.class.class.class.class.class { … }/* 100 = 100 */#id { … }
Different Intents universal/type » Reset / Normalizer type/attr » Initial Defaults attrs » Common Patterns attrs » Page Layouts attr > attr » Components ID » Overrides
Style sheets can be cascaded; the user/browser specifies initial preferences and hands the remaining influence over… – Håkon Lie
❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults
❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults
❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults
❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults
❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🏇🏽 Animations 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults
🎠 Transitions ❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🏇🏽 Animations 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults
🗺 Origin & ❗importance 🎠 Transitions ❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🏇🏽 Animations 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults 🎯 Selector Specificity ⏭ Source Order
🗺 Origin & ❗importance 🎠 Transitions ❗🖥 User Agent Important ❗👥 User Important ❗🎨 Author Important 🏇🏽 Animations 🎨 Author Styles 👥 User Preferences 🖥 User Agent Defaults 🎯 Selector Specificity ⏭ Source Order
filtering -> declared values? cascading -> cascaded value? defaulting -> specified value resolving -> computed value formatting -> used value? constraining -> actual value?