HOME HTML HTML5 CSS XML JAVASCRIPT ASP PHP SQL REFERENCES | EXAMPLES | FORUM | ABOUT

HTML5 TUTORIAL

HTML5 Home
HTML5 Introduction
HTML5 New Elements
HTML5 Video
HTML5 Audio
HTML5 Canvas
HTML5 Web Storage

HTML5 FORMS

HTML5 Input Types
HTML5 Form Elements
HTML5 Form Attributes

HTML5 REFERENCE

HTML5 Tags
HTML5 Attributes
HTML5 Events

HTML5 TAGS

<!-->
<!DOCTYPE>
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<article>
<aside>
<audio>
<b>
<base>
<basefont>
<bdo>
<big>
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<command>
<datalist>
<dd>
<del>
<details>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font>
<footer>
<form>
<frame>
<frameset>
<h1> - <h6>
<head>
<header>
<hgroup>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<keygen>
<kbd>
<label>
<legend>
<li>
<link>
<map>
<mark>
<menu>
<meta>
<meter>
<nav>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike>
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<tt>
<u>
<ul>
<var>
<video>
<wbr>
<xmp>

HTML5 <style> Tag

Example

Use of the style element in an HTML document:

<html>
<head>
<style type="text/css">
h1 {color:red}
p {color:blue}
</style>
</head>

<body>
<h1>Header 1</h1>
<p>A paragraph.</p>
</body>
</html>

Try it yourself »

Definition and Usage

The <style> tag is used to define style information for an HTML document.

Inside the style element you specify how HTML elements should render in a browser.


Differences Between HTML 4.01 and HTML5

The scoped attribute is new in HTML5, which allows you to define styles for a specified section of your document, instead of the entire document.

If the "scoped" attribute is present, the styles only apply to the style elements parent element and its child elements.


Tips and Notes

Tip: To link to an external style sheet, use the <link> tag.

Tip: To learn more about style sheets, visit our CSS Tutorial.

Note: If the scoped attribute is NOT defined, the <style> element must be placed in the <head> section.


Attributes

New : New in HTML5.

Attribute Value Description
type text/css Specifies the MIME type of the style sheet
media media query Specifies what media/device the media resource is optimized for. Default value: all.
scopedNew scoped If present, the styles should ONLY apply to the style elements parent element and its child elements.

Global Attributes

The <style> tag also supports the Global Attributes in HTML5.


Event Attributes

The <style> tag also supports the Event Attributes in HTML5.


Examples

» HTML Examples
» CSS Examples
» XML Examples
» JavaScript Examples
» HTML DOM Examples
» XML DOM Examples
» DHTML Examples
» AJAX Examples
» VBScript Examples
» ASP Examples
» ADO Examples
» ASP.NET Examples
» SVG Examples
w3cTutorial.com HOME | FORUM | ABOUT
w3cTutorial is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content.
While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright 2011 W3CTutorial.COM. All Rights Reserved.