Quiz: Do You know CSS fundamentals? (2025)
Are you front-end enough?
Quiz: Do You Know CSS?
- Modern CSS? 🤔
- Does CSS belong on your resume??? 🚀
- Multiple choice. 🤖 … How difficult can it be, eh?
Which selector best matches the following HTML?
<a id="home" name="home" href="/home">Home</a>The correct answer is a#home[name='home'], which matches both the id and name attributes. In standards-mode HTML, ID values are case-sensitive, so #Home does not match id="home". A space is a descendant combinator; it would target a different element within an ancestor rather than combine conditions on this same link.
The :contains() selector is not a standard CSS selector, but it is available in some JS libraries.
Which selector matches the following HTML button?
<button onclick="openModal()">Contact</button>The correct answer is button[onclick], which targets the existence of attribute onclick.
Note that :link only targets unvisited href links, ::click is not a valid pseudo-element, and :focus targets only the focused element.
Which selector matches the last link in the following HTML?
<nav> <a name="home" href="/home">Home</a> <a name="login" href="/login">Login</a> <a name="help" href="/help">Help</a></nav>The correct selector is a:last-child, which matches the last <a> when it is also the last child of its parent. nav:nth-child(3) would match a <nav> element that is the third child of its own parent.
Which selector will take priority?
The a#quote selector takes priority due to the ID, which has a higher specificity than tag or class-based selectors.
Which declaration horizontally centers inline text within its containing block?
Using text-align: center; is the correct way to center text in a block element. There is no CSS align property. margin: 0 auto; can center a block with a constrained width; it does not center text inside that block.
align-content aligns content in supported layout contexts, such as grid and multi-line flex containers; it is not the text-alignment property. text-content is not a valid CSS property.
How do you center content vertically inside a block container in modern flow layout?
Using align-content is the modern way to center the contents of a block container vertically in flow layout.
The align-items and justify-content properties are used for flexbox and grid layouts, but not flow.
Both margin: 0 auto; and margin: auto; center a block element horizontally, but not vertically.
Which selector has the lowest specificity?
:where(.card) .title has the lowest specificity. The :where() pseudo-class and everything inside it contributes 0-0-0, so only .title counts. :is(.card) .title keeps the specificity of .card, .card .title has two classes, and #card .title includes an ID.
