0
0
CSSmarkup~20 mins

Text alignment in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Text Alignment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding text alignment behavior
What will be the horizontal alignment of the text inside this <div> if the CSS rule text-align: justify; is applied?
CSS
&lt;div style="width: 300px; border: 1px solid black; text-align: justify;"&gt;This is a sample paragraph to test text alignment behavior.&lt;/div&gt;
AText lines will be stretched so that both left and right edges align with the container edges, except the last line.
BText will be centered horizontally in the container.
CText will be aligned only to the left edge of the container.
DText will be aligned only to the right edge of the container.
Attempts:
2 left
💡 Hint
Justify alignment spreads text evenly across the line width.
📝 Syntax
intermediate
1:30remaining
Correct CSS property for right text alignment
Which CSS rule correctly aligns text to the right inside a paragraph?
CSS
&lt;p&gt;Align me right&lt;/p&gt;
Ap { align-text: right; }
Bp { text-align: right; }
Cp { text-position: right; }
Dp { horizontal-align: right; }
Attempts:
2 left
💡 Hint
The correct CSS property starts with 'text-align'.
rendering
advanced
2:30remaining
Visual result of mixed text alignment
Given the following HTML and CSS, what will the text alignment be for the <span> inside the <div>?
CSS
&lt;style&gt;
  div { text-align: center; }
  span { text-align: left; display: inline-block; width: 100%; }
&lt;/style&gt;
&lt;div&gt;This is a &lt;span&gt;test&lt;/span&gt; text.&lt;/div&gt;
AThe &lt;span&gt; text alignment will be ignored and inherit the &lt;div&gt; alignment.
BThe &lt;span&gt; text will be centered along with the &lt;div&gt; text.
CThe &lt;span&gt; text will be aligned to the right inside the &lt;div&gt;.
DThe &lt;span&gt; text will be aligned to the left inside the centered &lt;div&gt;.
Attempts:
2 left
💡 Hint
Inline-block elements can have their own text alignment.
selector
advanced
2:00remaining
CSS selector specificity for text alignment
Which CSS rule will override the others to align text to the right for all paragraphs inside a section with class 'content'?
Ap { text-align: right !important; }
Bsection.content p { text-align: right; }
C.content p { text-align: right; }
D#main .content p { text-align: right; }
Attempts:
2 left
💡 Hint
The !important rule overrides normal specificity.
accessibility
expert
3:00remaining
Ensuring accessible text alignment for screen readers
Which practice helps maintain accessibility when using CSS text alignment for paragraphs?
AAvoid using text alignment and rely only on HTML tags like &lt;center&gt; for alignment.
BUse text alignment to reorder text content visually for better screen reader reading order.
CUse text alignment purely for visual layout and ensure semantic HTML structure remains unchanged.
DUse CSS to hide text and replace it with aligned images for better visual effect.
Attempts:
2 left
💡 Hint
Screen readers read content in source order, not visual alignment.