Which combination achieves a full-width decorative underline on a block-level element using a pseudo-element?

Study for the CSS Mastery Test. Boost your knowledge with flashcards and multiple-choice questions, featuring hints and explanations. Prepare effectively for your exam!

Multiple Choice

Which combination achieves a full-width decorative underline on a block-level element using a pseudo-element?

Explanation:
Using a pseudo-element to draw the underline is about adding a separate decorative layer that you control independently of the element’s content. The pseudo-element is created with content: '', then you absolutely position it at the bottom of the block and stretch it across the full width with width: 100% and left: 0; bottom: 0. The parent must have position: relative so the pseudo-element’s placement is tied to that block. A small height (like 2px) gives a clean line, and background: currentColor makes the underline automatically match the text color. This approach keeps the underline purely decorative, sits at the very bottom, and scales with the element’s width, unlike a text-decoration or a border on the element itself, which either isn’t a pseudo-element or can affect layout in other ways.

Using a pseudo-element to draw the underline is about adding a separate decorative layer that you control independently of the element’s content. The pseudo-element is created with content: '', then you absolutely position it at the bottom of the block and stretch it across the full width with width: 100% and left: 0; bottom: 0. The parent must have position: relative so the pseudo-element’s placement is tied to that block. A small height (like 2px) gives a clean line, and background: currentColor makes the underline automatically match the text color. This approach keeps the underline purely decorative, sits at the very bottom, and scales with the element’s width, unlike a text-decoration or a border on the element itself, which either isn’t a pseudo-element or can affect layout in other ways.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy