HTML - attributes - style

revision:


Content

"style" attribute: specifies inline style for an element syntax some examples


"style" attribute: specifies inline style for an element

top

The style attribute specifies an inline style for an element. The "style" attribute will override any style set globally, e.g. styles specified in the <style> tag or in an external style sheet.

The style attribute is part of the global attributes, and can be used on any HTML element.


syntax

top

<element style="property:value "></element>

The property is a CSS property. The value is a CSS value.

In "inline styling", the CSS rules are directly written inside the starting tag using the style attribute. The style attribute includes a series of CSS property and value pairs. Each "property : value" pair is separated by a semicolon ( ; )


some examples

top

This is a header

This is a paragraph.

codes:
                    <h3 style="color:darkgreen;text-align:center;">This is a header</h3>
                    <p class="spec" style="margin-left:3vw; color:crimson;">This is a paragraph.</p>
                

Example of Inline Style

First paragraph

Second paragraph

codes:
                    <h3 style="margin-left:3vw;color:Blue;font-size:25px;">Example of Inline Style  </h3>
                    <p class="spec" style="margin-left:3vw;color:red;">First paragraph</p>
                    <p class="spec" style="margin-left:5vw;color:green;font-size:40px;">Second paragraph</p>