HTML Styles
HTML styles are used to change the appearance of HTML elements. With styles, you can modify text color, background color, font size, font family, text alignment, and many other visual properties. Styles make web pages attractive and easier to read.
- HTML styles are applied using the
styleattribute. - Styles are written using CSS properties and values.
- Styles control the appearance of HTML elements.
- They help create visually appealing web pages.
What are HTML Styles?
The HTML style attribute is used to add inline CSS to an
element. It allows you to change colors, fonts, spacing, alignment,
and other visual aspects directly inside an HTML tag.
HTML Text Color
The CSS color property is used to change the text color.
<p style="color:red;">This text is red.</p>
This text is red.
HTML Background Color
The background-color property changes the background color
of an element.
<p style="background-color:yellow;">Highlighted text.</p>
Highlighted text.
HTML Font Size
The font-size property is used to change the size of text.
<p style="font-size:30px;">Large Text</p>
Large Text
HTML Font Family
The font-family property specifies the font style of text.
<p style="font-family:Verdana;">Styled text.</p>
Styled text.
HTML Text Alignment
The text-align property controls the horizontal alignment
of text.
<p style="text-align:center;">Centered Text</p>
Centered Text
Summary
HTML styles help control the appearance of web pages. Using the
style attribute, you can change text color, background
color, font size, font family, and alignment. Understanding HTML styles
is an important step toward learning CSS and modern web design.