style ... ⁄style
HTML5 style element
The style element allows you to add CSS rules in order to style your web page. »video
About style
- is an optional element »video
Display & support style
- display in browser »video
- display: none





Parents, children style
- style nested within elements »style parents
- elements nested within style »style children
»examples
»video
Attributes style
- required: scoped (if style tag is used in body section)
- optional: specific attributes(except scoped if style tag is used in body section), global attributes, event attributes
Observation: scoped attribute currently supported in Firefox only.
style ELEMENT vs. style ATTRIBUTE
The difference between the style element and the style attribute »video
Syntax style
1 | <> ... </> »video |
Attributes and Values style (comma separated)
< | attribute | = | "attribute_value(s)" | > | Video | Examples |
---|---|---|---|---|---|---|
1. specific attributes | ||||||
1. | media | = | all, braille, embossed, handheld print, projection, screen, speech tty, tv | »video | <media="screen"> CSS rules <⁄ > | |
2. | type | = | MIME type | »video | <type="text/css"> CSS rules <⁄ > | |
3. | scoped | = | "", , scoped | »video | <scoped> CSS rules <⁄ > | |
All Specific Attributes | ||||||
2. global attributes | ||||||
1. | accesskey | = | keyboard key | »img | ||
2. | class | = | class name | »html »img | ||
3. | contenteditable | = | "", , true, false | »html | ||
4. | contextmenu | = | menu id value | »html | ||
5. | data-* | = | value | - | ||
6. | dir | = | ltr, rtl, auto | »html | ||
7. | draggable | = | true, , false | »img | ||
8. | dropzone | = | copy, move, link, string:, file: | - | ||
9. | hidden | = | "", , hidden | »html »img | ||
10. | id | = | id name | »html »img | ||
11. | itemid | = | URL | - | ||
12. | itemprop | = | string | »link »a | ||
13. | itemref | = | string | - | ||
14. | itemscope | = | "", , itemscope | - | ||
15. | itemtype | = | absolute URL | - | ||
16. | lang | = | language code | »html »head»title »img | ||
17. | spellcheck | = | "", , true, false | »html | ||
18. | style | = | CSS property:value | »html »img | ||
19. | tabindex | = | integer | »img | ||
20. | title | = | text | »html »link»style »abbr»dfn »img »meter | <title="Lighter"> CSS rules </ > | |
21. | translate | = | "", yes, no | »html »img | ||
All Global Attributes | ||||||
3. global event attributes | ||||||
1. | onclick | = | script | » list | <element onclick="script" > ... | |
2. | ondblclick | = | script | » list | <element ondblclick="script" > ... | |
All Event Attributes |
Video demonstration style element
HTML5 style element: style your web page
min | video details |
---|---|
00:07 | video tutorial: style element, adding CSS rules purpose: styling a web page |
00:18 | start by adding the start tag: <style> |
00:24 | add the end tag: <⁄style> |
00:34 | adding CSS rules between the start tag, <style>,and the end tag<⁄style> |
00:39 | adding css rules: |
00:39 | 1. a color for the background body{background-color:#cccfff;} |
00:51 | test result: ok, background's color is now blue |
00:55 | let's center this paragraph |
01:00 | 2. center a paragraph: p{text-align:center} |
01:10 | test result: ok, the paragraph is now centered |
01:13 | let's make the hyperlink white |
01:16 | a new color for the hyperlink a{color:#fff;} |
01:23 | test result: ok, the hyperlink is now white |
01:26 | - one way of styling a web page is through style element - the css rules are added between the start tag and the end tag - style element placed inside head section creates an internal style sheet |