Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Text Decoration Styling with CSS
📖 Scenario: You are designing a simple webpage for a local bookstore. You want to make the book titles stand out by adding different text decorations like underline, overline, and line-through.
🎯 Goal: Create CSS rules to add different text decorations to three book title paragraphs: underline, overline, and line-through.
📋 What You'll Learn
Use the CSS text-decoration property
Apply underline to the first book title
Apply overline to the second book title
Apply line-through to the third book title
Use semantic HTML with <main> and <p> tags
💡 Why This Matters
🌍 Real World
Text decoration is commonly used in websites to highlight links, emphasize important text, or show deleted content with line-through.
💼 Career
Knowing how to style text decorations is essential for front-end developers to create visually appealing and accessible web pages.
Progress0 / 4 steps
1
Create the HTML structure with book titles
Write the HTML code to create a <main> section containing three paragraphs with the exact texts: Book One, Book Two, and Book Three. Each paragraph should have a class: underline, overline, and line-through respectively.
CSS
Hint
Use the <p> tag with the class attribute for each book title inside the <main> tag.
2
Add CSS selectors for each text decoration class
Create CSS rules for the classes .underline, .overline, and .line-through. For now, just write the selectors with empty curly braces.
CSS
Hint
Write CSS selectors for each class name followed by curly braces.
3
Apply the correct text decoration styles
Inside the CSS rule for .underline, set text-decoration to underline. For .overline, set text-decoration to overline. For .line-through, set text-decoration to line-through.
CSS
Hint
Use the CSS property text-decoration with the correct value inside each class.
4
Add a responsive font size for better readability
Add a CSS rule for the p tag that sets the font size to 1.5rem. This will make the book titles easier to read on all devices.
CSS
Hint
Use the selector p and set font-size to 1.5rem.
Practice
(1/5)
1. Which CSS property is used to add an underline to text?
easy
A. text-transform
B. font-style
C. line-height
D. text-decoration
Solution
Step 1: Identify the property for text lines
The property text-decoration controls lines like underline, overline, and line-through on text.
Step 2: Confirm the underline effect
Using text-decoration: underline; adds an underline to the text.
Final Answer:
text-decoration -> Option D
Quick Check:
Underline = text-decoration [OK]
Hint: Underline text with text-decoration property [OK]
Common Mistakes:
Confusing font-style with underline
Using text-transform which changes case
Using line-height which controls spacing
2. Which of the following is the correct syntax to add a line-through effect to text in CSS?
easy
A. text-decoration: strike;
B. text-decoration: line-through;
C. text-decoration: crossed;
D. text-decoration: overline;
Solution
Step 1: Recall valid text-decoration values
The valid values for text-decoration include underline, overline, and line-through.
Step 2: Match the line-through effect
The correct value to cross out text is line-through. Other options like strike or crossed are invalid.
Final Answer:
text-decoration: line-through; -> Option B
Quick Check:
Line-through = line-through [OK]
Hint: Use line-through for strike effect in text-decoration [OK]
Common Mistakes:
Using invalid values like strike or crossed
Confusing overline with line-through
Missing the colon or semicolon in syntax
3. What will be the visual effect of this CSS on a paragraph?
p { text-decoration: underline overline; }
medium
A. The paragraph text will only have an overline.
B. The paragraph text will only have an underline.
C. The paragraph text will have both an underline and an overline.
D. The paragraph text will have no decoration.
Solution
Step 1: Understand multiple values in text-decoration
The text-decoration property can accept multiple values separated by spaces to combine effects.
Step 2: Apply underline and overline together
Using underline overline applies both lines above and below the text simultaneously.
Final Answer:
The paragraph text will have both an underline and an overline. -> Option C