0
0
CSSmarkup~5 mins

Before pseudo-element in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the ::before pseudo-element in CSS?
It is a way to insert content before the content of an element without changing the HTML. It helps add decorative or informative content using CSS only.
Click to reveal answer
beginner
How do you add text before an element using ::before?
Use content property inside ::before. For example: p::before { content: 'Note: '; } adds 'Note: ' before every paragraph.
Click to reveal answer
intermediate
Can ::before add images or icons?
Yes! You can add images using content: url('image.png'); or use Unicode characters like icons with content: '\2605'; for a star symbol.
Click to reveal answer
beginner
Does ::before affect the actual HTML structure?
No, it only changes what the user sees by adding content visually before the element's content. The HTML stays the same.
Click to reveal answer
beginner
What must you always include when using ::before to show content?
You must include the content property. Without it, the ::before pseudo-element will not appear.
Click to reveal answer
Which CSS property is required to make ::before display content?
Adisplay
Bposition
Ccontent
Dvisibility
Where does the ::before pseudo-element insert content?
AAt the end of the document
BBefore the element's content inside the element
COutside the element in the HTML
DAfter the element's content
Can ::before change the HTML source code?
ANo, it only changes visual display
BYes, it adds new HTML elements
CYes, it edits the HTML
DNo, it deletes HTML elements
Which of these is a valid way to add a star symbol before a heading using ::before?
Ah1::before { content: '\2605'; }
Bh1::before { content: 'star'; }
Ch1::before { content: url('star.png'); }
DBoth C and D
What happens if you omit the content property in ::before?
AThe pseudo-element is invisible
BThe pseudo-element still shows
CThe element's content disappears
DThe browser shows an error
Explain how the ::before pseudo-element works and how you use it to add content before an element.
Think about adding decorations or notes without touching HTML.
You got /4 concepts.
    Describe a real-life example where using ::before would be helpful in a webpage design.
    Imagine you want to add something small before text without changing the page code.
    You got /4 concepts.