![]() |
VOOZH | about |
CSS fonts are used to style and enhance the appearance of text on a webpage, making it more readable and visually appealing. They help control how text looks and fits within the overall design.
Fonts in CSS are applied using specific properties that control the style and appearance of text.
The font-family property defines which font(s) should be used for text. You can provide a list of fonts as a fallback mechanism in case the preferred font is unavailable.
Syntax:
font-family: "Font Name", generic-font-name; In this example, the browser will first try to display the text in Arial. If Arial is not available, it will fall back to a sans-serif font.
The font-size property controls the size of the text. You can set the size in several units, including pixels (px), ems (em), and percentages (%).
Syntax:
font-size: value;The font-weight property controls the thickness of the text. It can accept values like normal, bold, or numeric values (100 to 900).
Syntax:
font-weight: value;Numeric values allow for finer control over weight (e.g., 100 for light, 900 for extra bold).
The font-style property defines the style of the font, typically italic or normal.
Syntax:
font-style: value;The line-height property defines the space between lines of text. Increasing line height improves readability, especially for long paragraphs.
Syntax:
line-height: value;This comparison highlights the difference between universally supported system fonts (web-safe) and designer-selected custom fonts used for unique web styling.
Web safe fonts are commonly supported across all browsers and operating systems. These fonts are pre-installed on most computers, ensuring your text appears the same across devices.
Common Web Safe Fonts
Custom fonts allow you to use fonts that are not pre-installed on a user’s device. You can load them using web fonts. The most popular method for using custom fonts is through Google Fonts, or by hosting fonts on your own server.
To make typography adaptable to different screen sizes, use responsive units like em, rem, %, or vw for font sizes. You can also combine CSS media queries with typography to ensure readability across devices.
To customize fonts effectively in web design, it’s crucial to understand the main CSS font properties: