Alignment and decoration
Definition and purpose
Text alignment positions inline content within a line; text decoration paints lines such as underlines. Logical alignment follows the writing direction.
Logical text alignment
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { text-align: start; } #b { text-align: start; direction: rtl; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>Both use logical start; RTL starts on the right in horizontal writing.
Syntax and mental model
text-align: start follows the inline start, unlike fixed left alignment. text-decoration: underline can be combined with color, style and thickness. Decoration propagates through inline content; setting none on a child need not remove a line drawn by its ancestor.
Recognizable link
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { text-decoration: underline; text-decoration-thickness: 2px; color: navy; } </style> </head> <body> <a id="a" href="#details">Read details</a> <p id="details">Details</p> </body></html>The link retains a visible underline.
Common mistakes
Do not remove link underlines without another reliable visual cue. Center alignment does not center the block box itself.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Line height and spacing. Next lesson: Wrapping, white space and overflow.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Alignment and decoration — knowledge check
Five questions on alignment and decoration.
In horizontal RTL, start aligns to which side?
What does text-align center center?
Which property sets underline thickness?
What should remain recognizable?
Can a child always remove an ancestor underline with none?