Introduction
The HTML <style> tag is used for declaring
style sheets within your HTML document. The <style> tag is supported in all major browsers. The required type attribute defines the content of the style element. The only possible value is "text/CSS". The style element always goes inside the head section.
let's look at an example. If you want
the color of some text to look red, the style attribute would look like this:
- style="color:red"
The style sheet property is "color". The value of the color is "red". Notice there is a colon in between color and red, not an
equal sign and there are no extra quote marks.
Insert style into an HTML tag, such as the
<DIV> tag. Place a semicolon after your first property and value, and add another. So if we want the text to be read and to be italic, we would do the
following:
<DIV style="color:red; font-style:italic">This
style for some red-hot italic text!</DIV>
Attributes
There are 3 kinds of attributes that you can add to your
HTML tags: Element-specific, global, and event handler content attributes. The attributes that you can add to this tag are listed below.
Element-Specific Attributes
Attributes Introduced by
HTML5
| Attributes | Description |
| Type | type is used to specify the content type which is generally text/CSS. |
| Media | 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. |
| Scoped | if the <style> tag is being used outside of the document <head>, it must have the scoped attribute. |
Global Attributes
The following attributes are standard across all HTML 5 tags.
|
HTML5
Global Attributes
|
||
| accesskey | draggable | style |
| class | hidden | tabindex |
| dir | spellcheck | |
| contenteditable | id | title |
| contextmenu | lang | |
Event Handler Content Attributes
Here are the standard HTML 5 event handler content
attributes.
| onabort | onerror* | onmousewheel |
| onblur* | onfocus* | onpause |
| oncanplay | onformchange | onplay |
| oncanplaythrough | onforminput | onplaying |
| onchange | oninput | onprogress |
| onclick | oninvalid | onratechange |
| oncontextmenu | onkeydown | onreadystatechange |
| ondblclick | onkeypress | onscroll |
| ondrag | onkeyup | onseeked |
| ondragend | onload* | onseeking |
| ondragenter | onloadeddata | onselect |
| ondragleave | onloadedmetadata | onshow |
| ondragover | onloadstart | onstalled |
| ondragstart | onmousedown | onsubmit |
| ondrop | onmousemove | onsuspend |
| ondurationchange | onmouseout | ontimeupdate |
| onemptied | onmouseover | onvolumechange |
| onended | onmouseup | onwaiting |



Comments
Join the conversation! Your thoughts help the community grow.