HTML & CSS · Junior · Question 36 of 75
Why doesn't a ::before with only width, height and background show up?
- 1Pseudo-elements don't support
backgroundor sizing - ✓Correct answer: The
contentproperty is missing - without it the pseudo-element isn't created - 3
::beforeonly works on links and buttons
Explanation
::before and ::after are generated only when content is set - even empty: content: "". They are also inline by default, so sizing needs display: block or inline-block (or positioning). They don't work on replaced elements like <img> and <input>.