This section introduces HTML style style tags.
Let's look at a piece of code first.
The above code means to change the background color of the webpage to black, the text color of the title to white, and the text of the paragraph to red.
You can see that the above code, whether it is the label <body>, <h1> or <p>, has a style in their label. Now we know that the style attribute is used to change the style of the HTML element.
HTML style attribute
the role of the tyle attribute : provides a general way to change the style of all HTML elements.
Styles were introduced in HTML 4 and are a new and preferred way to change the style of HTML elements. Wif HTML styles, you can add styles directly to HTML elements by using the style attribute, or indirectly in a separate style sheet (CSS file).
You can learn all about styles and CSS in our CSS tutorials.
In our HTML tutorial, we'll use the style attribute to explain the HTML style to you.
Deprecated labels and attributes
In HTML 4, there are several tags and attributes that are obsolete. Deprecated means that these tags and attributes will not be supported in future versions of HTML and XHTML.
The message here is clear: please avoid using these discarded tags and attributes!
The following tags and attributes should be avoided:
|<center>||Define the content that is centered.|
|<font> and <basefont>||Define HTML fonts.|
|<s> and <strike>||Define strike through|
|<u>||Define underlined text|
|Align||Define the alignment of the text|
|Bgcolor||Define background color|
|Color||Define text color|
For these tags and attributes: use style instead!
HTML style instance - background color
the background-color property defines the background color for the element:
The style attribute eliminates the "old" bgcolor attribute.
HTML style instance - font, color, and size
The font-family, color, and font-size properties define the font family, color, and font size of the text in the element, respectively:
The style attribute eliminates the old <font> tag and is no longer usable.
HTML style instance - text alignment
The text-align attribute specifies the horizontal alignment of the text in the element:
The style attribute eliminates the old "align" attribute.