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
- Which syntax identifies a modern pseudo-element? (A) :: (B) ## (C) %% (D) &&. Answer: A. Pseudo-elements use double-colon notation.
- 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.
- 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.
- Which pseudo-element styles selected text? (A) ::selection (B) ::after (C) :checked (D) :visited. Answer: A. ::selection styles the highlighted selection.
- 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.
- Which pseudo-element styles placeholder text? (A) ::placeholder (B) :placeholder-only (C) ::input-text-all (D) :required. Answer: A. ::placeholder targets placeholder text.
- 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.
- 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.
- 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.
- 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.