Home  >  Article  >  Web Front-end  >  HTML specifies the attribute style of the element's inline style

HTML specifies the attribute style of the element's inline style

黄舟
黄舟Original
2017-11-03 13:43:108836browse

Example

Use the style attribute in HTML documents:

<h1 style="color:blue; text-align:center">This is a header</h1>
<p style="color:red">This is a paragraph.</p>

Definition and usage

The style attribute specifies the inline style of the element

## The #style attribute will override any global style settings, such as those specified in the c9ccee2e6ea535a969eb3f532ad9fe89 tag or in an external style sheet.

Support

W3C: The "W3C" column indicates whether the attribute is defined in the W3C's HTML/XHTML recommendations.

IEFirefoxOperaSafariW3CYESYESYESYESYES
Syntax

<element style="value">

Attribute

ValueDescriptionstyle_definitionOne or more CSS properties and values ​​separated by semicolons.
The following are examples of several style attributes:

Use the style attribute to change the background color (bgcolor function)

<span style="font-size: 12pt;"><html>
<body style = "
<h1 stye = "background-color:red>This is a Heading</h1>
<p style = "background-color:green>This is a Paragraph</p>
</body>
</html></span>

The style attribute is eliminated The old "bgcolor" attribute has been replaced.

Use the style attribute to set color, font, and size

1 <html>
2 <body>
3 <h1 style = "font-family:verdana">A Heading</h1>
4 <p style = "font-family:arial;color:red;font-size:20px;">A Paragraph</p>
5 </body>
6 </html>

The style attribute eliminates the old 240cb830ca84ebaabbd07850110b414d tag.

The style attribute sets the way the text is aligned

1 <html>
2 <body>
3 <h1 style = "text-align:center;">A Heading</h1>
4 <p>The heading above is aligned to the center of the page</p>
5 </body>
6 </html>

The style attribute eliminates the align attribute.

The above is the detailed content of HTML specifies the attribute style of the element's inline style. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn