HTML style

This section introduces the style tag of HTML


Let us look at a piece of code first

    php.cn 

标题的颜色

我是标签的颜色

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:

28.png

## You can see that in the above code, regardless of the label ,

or

, 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
Defines the centered content.
and define HTML fonts.
and Define strikethrough text
Define underlined text


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:

    php.cn 


HTML style example - font, color and size


## HTML Style Example - Text Alignment
The text-align attribute specifies the horizontal alignment of text within an element:

    php.cn 

标题

学HTML PHP 就到m.sbmmt.com

The style attribute obsoletes the old "align " Attributes.

    php.cn 

标题

上面的标题在页面中进行了居中排列。上面的标题在页面中进行了居中排列。上面的标题在页面中进行了居中排列。

Continuing Learning

About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
align Define the alignment of text bgcolor Define the background color color Define the text color ## The #style attribute obsoletes the "old" bgcolor attribute.
    php.cn 
The font-family, color and font-size attributes define the elements respectively Font family, color and font size of Chinese text:
    php.cn 

标题

段落

style attribute obsolete the old tag and can no longer be used
    php.cn 

标题

段落

||
php.cn

标题的颜色

我是标签的颜色

submit Reset Code

# Properties

Description