**`<style>`** lets you write CSS directly inline in the HTML document rather than linking an external file with `<link rel="stylesheet">`. It's most often placed in `<head>` so styles are known before the body renders, avoiding a flash of unstyled content. It can also appear with a **`scoped`**-like effect in component-based frameworks (via CSS-in-JS tooling), though plain `<style>` in standard HTML always applies globally to the whole document, not just its immediate siblings.
1Understanding <style>
`<style>` lets you write CSS directly inline in the HTML document rather than linking an external file with <link rel="stylesheet">. It's most often placed in <head> so styles are known before the body renders, avoiding a flash of unstyled content. It can also appear with a `scoped`-like effect in component-based frameworks (via CSS-in-JS tooling), though plain <style> in standard HTML always applies globally to the whole document, not just its immediate siblings.
For a production site, an external stylesheet via <link> is usually better than <style> — it can be cached by the browser across page loads, while inline <style> content is re-downloaded with every single page.
<head>
<style>
body { margin: 0; font-family: sans-serif; }
h1 { color: #333; }
</style>
</head>2Practical Example
Here is a real-world application of <style> showing how it is used in production HTML.
<!-- Critical CSS inlined for fast first paint, full stylesheet loaded after -->
<style>
.hero { background: black; color: white; padding: 2rem; }
</style>
<link rel="stylesheet" href="/full-styles.css">3Best Practices
Follow these guidelines when working with <style>:
1. Prefer an external stylesheet (<link rel="stylesheet">) for anything beyond a handful of rules, for caching benefits
2. Use inline <style> for critical, above-the-fold CSS to avoid render-blocking a separate file request
3. Remember <style> rules apply document-wide, not just to nearby elements, unless you scope selectors carefully
Tip: For a production site, an external stylesheet via <link> is usually better than <style> — it can be cached by the browser across page loads, while inline <style> content is re-downloaded with every single page.
<head>
<style>
body { margin: 0; font-family: sans-serif; }
h1 { color: #333; }
</style>
</head>