CSS-wide keywords
Definition and purpose
CSS-wide keywords request specific defaulting or cascade behavior on a property. initial selects its specification initial value, inherit selects the parent computed value, unset chooses between those according to normal inheritance, and revert rolls back the current origin according to cascade rules.
Initial versus revert
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style>#a { display: initial; } #b { display: revert; }</style> </head> <body> <div id="a">Inline</div> <div id="b">Block</div> </body></html>Initial selects inline; reverting author display reveals the default div block style.
Syntax and mental model
For color, unset behaves like inherit; for padding, unset behaves like initial (zero). In a simple author rule, revert may reveal the user-agent style if no user rule intervenes. revert-layer concerns layers and is covered later. Initial is not necessarily what an unstyled HTML element looks like: display starts at inline but browsers normally make a div block.
Unset follows inheritance rules
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> .parent { color: navy; padding: 12px; } #a { color: unset; padding: unset; } </style> </head> <body> <div class="parent"> <span id="a">Text</span> </div> </body></html>Color inherits; padding returns to its initial zero.
Common mistakes
Do not use initial as a synonym for browser default. Avoid resetting an entire component blindly; changing display or focus styles can alter usability.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Inheritance and defaulting. Next lesson: Importance and inline styles.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
CSS-wide keywords — knowledge check
Five questions on css-wide keywords.
What does initial select?
What does unset do for color?
What does unset do for padding?
What can revert reveal on an ordinary div with no user rule?
Which keyword explicitly copies a parent computed value?