The meaning of the above code is to change the background color of the web page to black, and the text of the title The color turns to white, and the text of the paragraph turns to red.
Code running results:
## You can see that in the above code, regardless of the label <body> ,<h1> or <p>, their tags all have style. Now we know that the style attribute is used to change the style of HTML elements.
The style attribute of HTML
The role of the style attribute : Provides a common way to change the style of all HTML elements.
Styles were introduced in HTML 4 and are the new preferred way to change the style of HTML elements. HTML styles allow you to add styles directly to HTML elements using the style attribute, or indirectly by defining them in a separate style sheet (CSS file).
You can learn all about styles and CSS in our CSS tutorials.
In our HTML tutorial, we will teach you about HTML styles using the style attribute.
Deprecated tags and attributes
In HTML 4, several tags and attributes are deprecated. 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 deprecated tags and attributes!
The following tags and attributes should be avoided:
Tag
Attribute
<center>
Defines the centered content.
<font> and <basefont>
define HTML fonts.
<s> and <strike>
Define strikethrough text
<u>
Define underlined text
# Properties
Description
align
Define the alignment of text
bgcolor
Define the background color
color
Define the text color
For the above tags and attributes: please use styles instead!
HTML Style Example - Background Color
The background-color attribute defines the background color for the element:
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning