HTML <style> tag


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

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

Try it yourself

Browser Support

IE Firefox Chrome Safari Opera

All major browsers support the <style> tag.

Definition and Usage

<Style> tag is used to define style information for HTML documents.

In style, you can specify the browser how to render the HTML document.

type attribute is required, define the contents of style elements. The only possible value is "text / css".

style element located head portion.

Tips and Notes

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

Tip: To learn more about style sheets, please read our CSS tutorial .

Differences between HTML and XHTML


Required attributes

Attributes value description
type text / css MIME type specified stylesheet.

Optional attributes

Attributes value description
  • screen
  • tty
  • tv
  • projection
  • handheld
  • print
  • braille
  • aural
  • all
Stylesheet specify different media types.

Global Properties

<style> tag supports HTML in the global properties .

Event Properties

<style> tag supports HTML in the event properties .

Examples TIY

HTML in style
This example demonstrates how to use the information to add to the style <head> section of the HTML format.
No underlined link
This example demonstrates how to use a style attribute do not underline links.
Link to an external stylesheet
This example demonstrates how <link> tag to link to an external stylesheet.

Related Pages

HTML DOM Reference: Style Objects