html tutorial - style Attribute in HTML - html5 - html code - html form



Style attribute in html

Learn html - html tutorial - Style attribute in html - html examples - html programs

  • The style attribute defines an inline style for an element.
  • The style attribute will override any style set globally.
  • The style attribute is a part of the Global Attributes.

Syntax for style attribute in HTML:

<element style="style_definitions">

Differences Between HTML 4.01 and HTML5 for style attribute in HTML:

HTML 4.0.1

  • <base>, <head>, <html>, <meta>, <param>, <script>, <style>, and <title> tags are not supported in HTML4.0.1.

HTML5

  • The style attribute can be used on any HTML element.

Applies to:

Elements Attribute
All HTML Elements style

Attributes Values of size attribute in HTML:

Value Description
style_definitions One or more CSS properties and values divided by semicolons

Sample coding for style attribute in HTML

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy HTML style Attribute</title>
    </head>
    <body>
        <h1 style="color:blue;text-align:center;">Welcome to wikitechy.com 
        </h1>
    </body>
</html>

Code Explanation for style attribute in HTML

style Attribute Code Explanation

  1. style attribute used to define the style for the element.
  2. The Background color sets by Cyan.
  3. style="color:blue; text-align:center;" is used to set the color as blue and show the contents in center alignment for the <h1> tag.

Sample Output for style attribute in HTML

style Attribute Output

  1. The style blue color and center alignment is applied to “Welcome to wikitechy.com”.

Browser Support for style attribute in HTML

Yes Yes Yes Yes Yes

Related Searches to style attribute in html