HomeReferencesHTML Tags

HTML Tag: style

Used to define CSS at a page-level (as opposed to an external CSS file). A style element must appear inside the head element.

HTML Dog, The Book HTML Dog book cover

HTML Dog is hosted by Titan Internet

Required Attributes

  • type is used to specify the content type which is generally text/css.

Optional Attributes

  • media can be used to specify which media the styles are associated to. A value such as screen, print, projection, braille, speech or all can be used or a combination in a comma-separated list.
  • title can be used to assign a title to the styles within the element. This can be then be referenced by browsers or scripting languages to either disable the styles or switch between alternate style sheets.
  • I18n attributes

Example


<style type="text/css">
	body {
		color: red;
		background-color: yellow;
		font-size: 80%;
	}
	p {
		line-height: 1.5em;
	}
</style>