w3schools    w3Schools
Search :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
HTML Reference
HTML by Alphabet
HTML by Function
HTML Attributes
HTML Events
HTML Colornames
HTML Character Sets
HTML ASCII
HTML ISO-8859-1
HTML Symbols
HTML URL Encode
HTML Lang Codes
HTTP Messages

HTML Tags
<!-->
<!DOCTYPE>
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<b>
<base>
<basefont>
<bdo>
<big>
<blockquote>
<body>
<br>
<button>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<dd>
<del>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<fieldset>
<font>
<form>
<frame>
<frameset>
<head>
<h1> - <h6>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<label>
<legend>
<li>
<link>
<map>
<menu>
<meta>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<p>
<param>
<pre>
<q>
<s>
<samp>
<script>
<select>
<small>
<span>
<strike>
<strong>
<style>
<sub>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<title>
<tr>
<tt>
<u>
<ul>
<var>

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

Browse Tutorials
 

HTML style Attribute


HTML Standard Attributes Reference HTML Standard Attributes

Definition and Usage

The style attribute specifies an inline style for the element.

The style attribute will override any style set globally (in the <style> tag or in a linked stylesheet).

The class attribute is mostly used with CSS to style elements. It can also be used with JavaScript (using the HTML DOM) to change the HTML element with the specified class.

Syntax

<element style="style-data">
Some text or element</element>
OR
<element style="style-data" />

Parameter Description
style_data Required. A single, or a series of CSS property and values separated by semicolons.
element Required. The HTML element using the style.

The style attribute can be used on almost all HTML elements.

Exceptions:

  • base
  • head
  • html
  • meta
  • param
  • script
  • style
  • title


Support

W3C: The "W3C" column indicates whether or not the attribute is defined in the W3C HTML/XHTML recommendation.

Internet Explorer Firefox Opera Safari W3C
YES YES YES YES YES


Example

Source Output
<p style="text-align:center;color:blue;">
Hello World</p>
<p style="color:#1E90FF">
An inline style example</p>

Hello World

An inline style example



Try-It-Yourself Demos

The style attribute
How to use the style attribute.


HTML Standard Attributes Reference HTML Standard Attributes