The HTML Style Attribute
The purpose of the style attribute is:
- The style attribute is used to style HTML elements.
- To provide a common way to style all HTML elements.
- With HTML styles, styles can be added to HTML elements directly by using the style attribute, or indirectly in separate style sheets (CSS files).
HTML Background Color Style
- The background-color property defines the background color for an element.
HTML Background color style Example | |
---|---|
HTML Code | PREVIEW |
<html> <body style="background-color:blue"> <h2 style="background-color:green">This is a heading</h2> <p style="background-color:red">This is a paragraph.</p> </body> </html> | This is a headingThis is a paragraph. |
HTML FONTS,SIZE,COLOR STYLE
- The font-family, color, and font-size properties defines the font, color, and size of the text in an element.
HTML Color,Size,Font style Example | |
---|---|
HTML Code | PREVIEW |
<html> <body> <h1 style="font-family:verdana">This is a heading</h1> <p style="font-family:arial;color:blue;font-size:20px;">This is a paragraph.</p> </body> </html>; | This is a heading This is a paragraph. |
HTML Text Alignment Style
- The text-align property specifies the horizontal alignment of text in an element
- The style attribute makes the old "align" attribute obsolete.
HTML Text Aligment Style Example | |
---|---|
HTML Code | PREVIEW |
<html> <body> <h1 style="text-align:left">This</h1> <p>The heading above is aligned to the center of this page.</p> </body> </html>; | ThisThe heading above is aligned to the left of this page. |
0 comments:
Post a Comment
Please leave some comment.