0
0
CSSmarkup~20 mins

Before pseudo-element in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Before Pseudo-element Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What will be displayed by this CSS?
Given the HTML and CSS below, what text will appear before the paragraph content in the browser?
CSS
/* HTML */
<p class="note">Remember to save your work.</p>

/* CSS */
p.note::before {
  content: "Note: ";
  color: red;
  font-weight: bold;
}
AThe text 'Remember to save your work.' appears in red and bold with no prefix.
BThe text 'Note: ' appears after the paragraph content.
COnly 'Remember to save your work.' appears with no changes.
DThe text 'Note: ' in red and bold appears before 'Remember to save your work.'
Attempts:
2 left
💡 Hint
The ::before pseudo-element inserts content before the element's actual content.
selector
intermediate
2:00remaining
Which selector correctly applies ::before to all list items?
You want to add a dash before every list item in an unordered list. Which CSS selector correctly targets all
  • elements to add content before them?
  • Aul::before li
    Bul li::before
    Cli::before ul
    Dul li:before
    Attempts:
    2 left
    💡 Hint
    The ::before pseudo-element is attached directly to the element you want to style.
    🧠 Conceptual
    advanced
    2:00remaining
    Why might ::before content not appear?
    Consider this CSS: p::before { content: "Hello"; display: block; width: 0; height: 0; } Why might the 'Hello' text not be visible in the browser?
    ABecause ::before only works on block elements, and <p> is inline.
    BBecause content property is only for images, not text.
    CBecause width and height are zero, the content has no visible area to display.
    DBecause display: block hides the content.
    Attempts:
    2 left
    💡 Hint
    Think about how width and height affect visibility of elements.
    accessibility
    advanced
    2:00remaining
    What is an accessibility concern with ::before content?
    If you add important text using ::before, what accessibility issue might arise?
    AScreen readers may not read the ::before content, so important info can be missed.
    B::before content causes color contrast issues automatically.
    C::before content disables keyboard navigation on the element.
    D::before content is always read first by screen readers, causing confusion.
    Attempts:
    2 left
    💡 Hint
    Think about how assistive technologies read content added by CSS.
    📝 Syntax
    expert
    2:00remaining
    What error occurs with this CSS?
    What happens when you use this CSS code? h1::before { content: Hello; color: blue; }
    CSS
    h1::before {
      content: Hello;
      color: blue;
    }
    AThe browser ignores the content property because Hello is not in quotes, so no text appears.
    BThe browser shows the word Hello before every h1 in blue.
    CA syntax error stops all CSS from loading.
    DThe color property is ignored but content shows correctly.
    Attempts:
    2 left
    💡 Hint
    The content property requires text to be in quotes.