Tutorials
CSSIn this tutorial you will learn about Cascading Style Sheets (CSS), Fonts, Font family,Font size, Font weight, Font style and Font variant.
To set the font for a specific text, use the property “font-family”, the value can be more than one family separated with a comma, the browser will display the text using the first font, if it's not supported by the operating system, it will use the next font, if no font is supported, it will use the default font.
body
{
font: Arial, Helvetica, sans-serif;
}
This sets the HTML document font to one of the specified fonts starting from left, if no font is supported, then the browser default font is used.
To set the font size, use the property “font-size”, the value can be one of the following values:
xx-small, x-small, small, medium, large, x-large, xx-large, smaller, or larger
It can be also a length value or a percentage.
Body
{
font-size: 12px;
}
This sets the font size of the whole HTML document to 12 pixels.
To set the weight of a font, use the property “font-weight”, the value can be one of the following values:
normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, or 900
.strong
{
font-weight: bold;
}
This sets all the text of the elements that use this class to be bold.
To set the style of a font, use the property “font-style”, the value can be one of the following values:
normal, italic, or oblique.
.italic
{
font-style: italic;
}
This sets all the text of the elements that use this class to be italic.
To set the variant of a font, use the property “font-variant”, the value can be one of the following values:
normal or small-caps.
.caps
{
font-variant: small-caps;
}
This sets all the text of the elements that use this class to be uppercase.