<style>
Embeds CSS right into the HTML page.
Syntax
<style> selector { property: value; } </style>Attributes
| Parameter | Type | Description |
|---|---|---|
| media | media query | Optional. Which screens the styles apply to. |
Examples
Styles inside the page:
<style>
h2 { color: teal; }
.note { background: lightyellow; padding: 8px; }
</style>
<h2>Opening hours</h2>
<p class="note">Open daily from 8 am to 9 pm.</p>Notes
Usually <style> goes into <head>. Embedded styles are handy for a single page and for examples, but for a site it is better to move CSS into a separate file and connect it with <link> — then every page can use it.
See also
Related recipes
In the tutorial
- What is CSS — How a CSS rule works, where to write styles, how to attach a separate file and why comments are useful.