Skip to content

Courses / CSS3 Mastery: Beginner to Advanced / Pseudo-Elements

2,089 people viewed this

Pseudo-Elements

Practice Exercise

Create a notice card with a decorative icon, a drop-cap introduction, styled selected text, and custom list markers. Verify that the notice still makes sense when generated content is unavailable.

Quiz — 10 MCQs

  1. Which syntax identifies a modern pseudo-element? (A) :: (B) ## (C) %% (D) &&. Answer: A. Pseudo-elements use double-colon notation.
  2. Which pseudo-element generates content before an element's content? (A) ::before (B) :hover (C) :focus (D) ::selection. Answer: A. ::before creates a generated box before the content.
  3. Which property is commonly needed for generated text? (A) content (B) z-index only (C) href (D) action. Answer: A. The content property defines generated content.
  4. Which pseudo-element styles selected text? (A) ::selection (B) ::after (C) :checked (D) :visited. Answer: A. ::selection styles the highlighted selection.
  5. Which pseudo-element styles list markers? (A) ::marker (B) :marker only (C) ::list-item-text (D) :first-child. Answer: A. ::marker targets list marker styling.
  6. Which pseudo-element styles placeholder text? (A) ::placeholder (B) :placeholder-only (C) ::input-text-all (D) :required. Answer: A. ::placeholder targets placeholder text.
  7. What does ::first-letter style? (A) The first typographic letter (B) Every letter (C) The first HTML element (D) A document title. Answer: A. It targets the first typographic letter where applicable.
  8. What is a good use of ::before? (A) Decorative visual marker (B) Storing critical database records (C) Replacing semantic HTML entirely (D) Running JavaScript. Answer: A. It works well for decorative additions.
  9. Should essential form labels exist only in ::before? (A) Yes (B) No (C) Only on desktop (D) Only with Grid. Answer: B. Use proper semantic labels for accessible forms.
  10. How does a pseudo-class differ from a pseudo-element? (A) A pseudo-class matches states or relationships; a pseudo-element targets a part or generated box (B) They are identical in every respect (C) Pseudo-classes only work in HTML (D) Pseudo-elements are JavaScript functions. Answer: A. They represent different selector concepts.

Key Takeaways

  • Pseudo-elements target parts of elements or generated boxes.
  • ::before and ::after are useful for decoration.
  • Use semantic HTML for essential information and accessible labels.

Rate this course

No ratings yet — yours can be the first.

Stars show on this course. Your written note stays private.

Your stars