0% completed
Text decoration and line height are vital for controlling the appearance and spacing of text. Text decoration adds visual markers like underlines, overlines, or strike-throughs to your text, while line height defines the vertical spacing between lines. Together, these properties help to improve readability and create emphasis where needed.
Follow the code block below to set text decoration and line height in CSS:
/* Set text decoration */ text-decoration: none | underline | overline | line-through | blink; /* Set line height */ line-height: normal | number | length | percentage;
Explanation:
normal
, a numerical value (e.g., 1.5
), fixed lengths (e.g., 20px
), or a percentage (e.g., 150%
).In this example, we style a paragraph to have an underline text decoration and a larger line height for improved readability.
Explanation:
underline
value adds a line below the text.1.8
increases the spacing between lines relative to the font size.In this example, we apply a strike-through effect to a heading and adjust the line height to demonstrate how different text decorations and line height settings change the text appearance.
Explanation:
line-through
value draws a line across the text, creating a strike-through effect.2
doubles the spacing between lines, which is useful for larger text or titles.This lesson demonstrates how text decoration and line height can be applied to enhance the visual appearance of your text. By using these properties, you can create attractive and readable layouts for your web pages.
.....
.....
.....