Member-only story
CSS text formatting
For more questions and answers visit our website at Frontend Interview Questions
Basic Text Formatting Properties in CSS
- Font Family (
font-family): Specifies the typeface for text, enabling custom fonts on a webpage.
p {
font-family: Arial, sans-serif;
}Explanation: The font-family property assigns the font used for the <p> element. If "Arial" isn’t available, the browser falls back to the default sans-serif font.
2. Font Size (font-size): Controls the size of the text.
h1 {
font-size: 32px;
}Explanation: The font-size property sets the text size of the <h1> element to 32 pixels.
3. Font Weight (font-weight): Defines the boldness of the text.
strong {
font-weight: bold;
}Explanation: The font-weight property makes the <strong> text bold. You can also use numeric values like 400 for normal weight and 700 for bold.
4. Font Style (font-style): Specifies whether text should be italicized.
em {
font-style: italic;
}Explanation: The font-style property italicizes the text in the <em> element.








