HTML4 HTML5
The <style> tag is used to embed CSS rules directly inside an HTML document (internal styles)[cite: 3]. It allows styling page elements like colors, fonts, layouts, and spacing without separate CSS files[cite: 3].
It is most commonly placed in the <head> section, though HTML5 permits usage inside <body>[cite: 3].
Both opening and closing tags are mandatory[cite: 3].
Attributes:
media – specifies target media/conditions (e.g., media="print") for CSS rules[cite: 3].class, id, and style are also used[cite: 3].In the example below, the <style> tag defines heading and paragraph styling using CSS rules[cite: 3]:
Code:
The browser will interpret this code as follows:
This is a paragraph with custom background and left border.