HTML styles change how elements look—color, size, font, alignment, and more—using CSS. The HTML style attribute adds CSS to one element. You can also put CSS in a <style> element or link an external stylesheet.
What does the style attribute do?
It holds one or more CSS declarations: property: value; pairs. Example: style="color:blue;font-size:18px;".
Three ways to add styles
Inline (style attribute), internal (<style> in <head>), and external (<link rel="stylesheet">). For a deeper walkthrough of all three, see How to Add CSS to HTML.
When should you use each?
Use the style attribute for quick Try It demos. Prefer a <style> block while learning in one file. Use an external CSS file for real multi-page sites.
CSS property = look.
HTML describes structure; CSS describes presentation. Styles tutorials teach the bridge between them.
Syntax reminder.
<tagname style="property: value;"> — property and value are CSS, not HTML attribute names.
Do not overuse inline styles.
They are hard to reuse and override. Move shared rules into CSS classes as soon as patterns repeat.
Syntax
HTML Style Syntax
The style attribute form:
style-attr.html
<tagnamestyle="property: value;">
HTML
<body style="background-color:powderblue;">
<h1 style="color:blue;">This is a heading</h1>
<p style="font-family:verdana;font-size:16px;">This is a paragraph.</p>
</body>
Separate multiple declarations with semicolons. Property names use hyphens in CSS (font-size, background-color, text-align).
Reference
Core HTML Concepts
Starter CSS properties used with HTML:
Property
Controls
Example value
background-color
Background fill
powderblue
color
Text color
blue
font-family
Typeface
verdana
font-size
Text size
20px or 150%
text-align
Horizontal alignment
center
Inline vs internal vs external
Method
Where
Best for
Inline
style attribute
One-off demos
Internal
<style> in <head>
Single-page practice
External
<link rel="stylesheet">
Real websites
Approach
How to Style HTML
A simple path from attribute to stylesheet.
Start with the style attribute on a heading or paragraph.
Try background-color, color, font-family, font-size, and text-align.
Move repeated rules into a <style> block with selectors (h1, .note).
When the page grows, extract CSS to a .css file and link it.
Keep HTML for structure; keep visual rules in CSS.
One line: Style HTML with CSS via the style attribute, a style element, or an external stylesheet—structure stays in HTML, look stays in CSS.
Frequently Asked Questions
The style attribute adds CSS declarations to one element, such as color, font-size, or background-color. Syntax: style="property: value;". Use it for quick demos; prefer a stylesheet for real sites.
Beginners usually start with background-color, color, font-family, font-size, and text-align. Each property takes a CSS value (for example color: blue; or font-size: 20px;).
The style element holds CSS rules inside the HTML document, usually in head. Example: <style> h1 { color: navy; } </style>. It styles many elements without repeating the style attribute.
In head, add <link rel="stylesheet" href="styles.css">. The browser loads that file and applies its rules. See the Add CSS to HTML tutorial for full details.
External CSS is best for most websites. Use a style block while learning in one file. Reserve the style attribute for one-off overrides or tiny examples.
Usually yes—inline style has high specificity and often wins over linked or internal CSS, unless the stylesheet uses !important (avoid that as a beginner).