Prelims - Text Flashcards
The color property is used to set the color of the text. The color is specified by:
a color name - like “red”
a HEX value - like “#ff0000”
an RGB value - like “rgb(255,0,0)
body { color: blue; } h1 { color: green; }
Specifies the color of text
color
Specifies the background color of text
` background-color`
property is used to set the horizontal alignment of a text.
text-align
h1 { text-align: center; } h2 { text-align: left; } h3 { text-align: right; } h4 { text-align: justify }
property specifies how to align the last line of a text.
text-align-last
p.a { text-align-last: right; } p.b { text-align-last: center; } p.c { text-align-last: justify; }
properties can be used to change the text direction of an element
direction
and unicode-bidi
p { direction: rtl; unicode-bidi: bidi-override; }
property sets the vertical alignment of an element
vertical-align
img.a { vertical-align: baseline; } img.b { vertical-align: text-top; } img.c { vertical-align: text-bottom; } img.d { vertical-align: sub; } img.e { vertical-align: super; }
Specifies the text direction/writing direction
direction
Used together with the direction property to set or return whether the text should be overridden to support multiple languages in the same document
unicode-bidi
property is used to add a decoration line to text
text-decoration-line
h1 { text-decoration-line: overline; } h2 { text-decoration-line: line-through; } h3 { text-decoration-line: underline; } p { text-decoration-line: overline underline; }
property is used to set the color of the decoration line
text-decoration-color
h1 { text-decoration-line: overline; text-decoration-color: red; } h2 { text-decoration-line: line-through; text-decoration-color: blue; } h3 { text-decoration-line: underline; text-decoration-color: green; } p { text-decoration-line: overline underline; text-decoration-color: purple; }
property is used to set the style of the decoration line
text-decoration-style
h1 { text-decoration-line: underline; text-decoration-style: solid; } h2 { text-decoration-line: underline; text-decoration-style: double; } h3 { text-decoration-line: underline; text-decoration-style: dotted; } p.ex1 { text-decoration-line: underline; text-decoration-style: dashed; } p.ex2 { text-decoration-line: underline; text-decoration-style: wavy; } p.ex3 { text-decoration-line: underline; text-decoration-color: red; text-decoration-style: wavy; }
The text-decoration property is a shorthand property for
text-decoration-line (required)
text-decoration-color (optional)
text-decoration-style (optional)
text-decoration-thickness (optional)
h1 { text-decoration: underline; } h2 { text-decoration: underline red; } h3 { text-decoration: underline red double; } p { text-decoration: underline red double 5px; }
is used to remove the underline from links
text-decoration: none
a { text-decoration: none; }
Specifies the thickness of the text decoration line
text-decoration-thickness