style element
Holds CSS rules inside the HTML document.
Learn Internal CSS as the bridge between clean HTML and professional CSS: visual hierarchy, maintainable styling, responsive behavior and live practice.
HTML styling foundation
Internal CSS lives inside a style element, usually in the head of the HTML document. It is useful for demos, teaching pages, one-page prototypes and small standalone pages.
It is more maintainable than inline CSS because selectors and declarations live in one place. But it still belongs to one document. If many pages need the same styles, external CSS is usually better.
Internal CSS is a good learning step because you can see HTML and CSS together without creating extra files yet.
Holds CSS rules inside the HTML document.
The style element usually belongs in head before the visible body content.
Great for one page, weaker for shared design systems.
Useful when one file should show the complete example.
Syntax and structure
The CSS syntax is the same as in an external file. The difference is only where the CSS lives.
<head> <style> .lesson-card { max-width: 720px; margin: 40px auto; padding: 32px; border-radius: 24px; background: #101a2d; color: white; } </style> </head> <body> <article class="lesson-card">...</article> </body>
<!-- index.html --> <style>.button { background: #dc1f36; }</style> <!-- about.html --> <style>.button { background: #dc1f36; }</style> <!-- contact.html --> <style>.button { background: #dd2239; }</style>
HTML quick reference
Use these patterns when you need the syntax quickly. Each example has its own anchor, so search engines and readers can land directly on the exact pattern instead of only at the top of the lesson.
A clean version of the markup from this lesson. Use it when you need the correct HTML shape quickly.
<head> <style> .lesson-card { max-width: 720px; margin: 40px auto; padding: 32px; border-radius: 24px; background: #101a2d; color: white; } </style> </head> <body> <article class="lesson-card">...</article> </body>
Meaningful markup that stays understandable before CSS and JavaScript are added.
The starting point from the practice lab. Change the HTML first, then use CSS only for presentation.
<main class="landing"> <p class="eyebrow">Internal CSS</p> <h1>One page, one local style system.</h1> <p>Use selectors to style the page without touching the meaning of the HTML.</p> <button type="button">Start lesson</button> </main> <style> body { margin: 0; min-height: 100vh; display: grid; place-items: center; font-family: Inter, system-ui, sans-serif; background: #f4f1ea; color: #101620; } .landing { width: min(760px, calc(100% - 32px)); padding: 42px; border-radius: 28px; background: white; box-shadow: 0 26px 80px rgba(16, 22, 32, 0.16); } .eyebrow { color: #dc1f36; font-weight: 900; text-transform: uppercase; } h1 { font-size: 48px; line-height: 1; margin: 12px 0 16px; } p { color: #4b5565; font-size: 18px; line-height: 1.7; } button { border: 0; border-radius: 999px; padding: 14px 20px; background: #101620; color: white; font-weight: 800; } button:focus-visible { outline: 4px solid #62d5ff; outline-offset: 4px; } </style>
A complete practice snippet that shows how the HTML behaves in context.
A weak pattern from the lesson. Use it as a warning sign when reviewing real pages.
<!-- index.html --> <style>.button { background: #dc1f36; }</style> <!-- about.html --> <style>.button { background: #dc1f36; }</style> <!-- contact.html --> <style>.button { background: #dd2239; }</style>
A recognizable mistake you can search for and refactor.
Rules that matter
Styling is not only making something look nice once. Good CSS stays readable, reusable and predictable while the project grows.
The browser can discover styles before painting the page.
Write classes and element selectors, not only one-off hacks.
If the internal CSS becomes long or repeated, move it to an external file.
A small demo can live in one file. A product usually needs separated assets.
Comment sections when the CSS grows, but avoid explaining obvious declarations.
Group base styles, layout, components and utilities so you can find things later.
Production thinking
This matters because internal CSS teaches the separation of structure and styling without adding file management yet. It is the stepping stone between style attributes and real stylesheets.
Internal CSS can style focus states, contrast and readable typography. Never remove outlines unless you replace them with an equally clear focus style.
Internal CSS can be useful for critical CSS or small landing pages, but shared websites usually need external stylesheets for caching and consistency.
Internal CSS can help render a page quickly when used carefully, but bloated style blocks make HTML heavier and harder to maintain.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.