0
0
CSSmarkup~20 mins

Line height in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Line Height Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding line-height unitless values
What is the effect of setting line-height to a unitless number like 1.5 in CSS?
AIt multiplies the element's font size by 1.5 to determine the line height.
BIt sets the line height to exactly 1.5 pixels.
CIt sets the line height to 1.5 times the browser default line height, ignoring font size.
DIt sets the line height to 1.5 em units regardless of font size.
Attempts:
2 left
💡 Hint
Think about how line height relates to font size when no unit is specified.
📝 Syntax
intermediate
2:00remaining
Which CSS line-height declarations are valid?
Which of the following CSS line-height declarations are valid and will not cause a syntax error?
Aline-height: 1.5px;
Bline-height: 1.5em;
Cline-height: 150%;
Dline-height: 1.5pt;
Attempts:
2 left
💡 Hint
line-height accepts unitless numbers, percentages, and all standard length units like em, px, pt.
rendering
advanced
2:00remaining
Visual difference of line-height values
Given the following CSS, what will the vertical spacing between lines look like in the browser?
CSS
p {
  font-size: 16px;
  line-height: 2;
}
ALines will have a fixed 2px space between them regardless of font size.
BLines will have no extra spacing beyond the font size.
CLines will have double the font size space between them, creating large vertical gaps.
DLines will be spaced very tightly, almost overlapping.
Attempts:
2 left
💡 Hint
Consider what multiplying the font size by 2 means for line spacing.
selector
advanced
2:00remaining
Applying line-height to nested elements
If a parent <div> has line-height: 1.5; and a child <span> inside it has line-height: 2;, what line height will the child text have?
CSS
<div style="line-height: 1.5;">
  <span style="line-height: 2;">Text</span>
</div>
AThe child text will have line height 2 times the parent's font size.
BThe child text will inherit the parent's line height of 1.5.
CThe child text will have line height 1.5 times its font size.
DThe child text will have line height 2 times its own font size.
Attempts:
2 left
💡 Hint
Remember how CSS inheritance and unitless line-height values work.
accessibility
expert
3:00remaining
Choosing line-height for readability and accessibility
Which line-height value is generally best for improving readability and accessibility of body text on a webpage?
Aline-height: 1;
Bline-height: 1.5;
Cline-height: 1.2;
Dline-height: 2.5;
Attempts:
2 left
💡 Hint
Think about comfortable spacing that helps the eye track lines without too much gap.