The style attribute lets you apply CSS directly to a single element — no stylesheet needed.
style="" attributes — no external CSS, no <style> blockfont-size, font-weight, line-height, letter-spacing, and color are all fair gameThere are three places CSS can live:
<link rel="stylesheet" href="style.css"> in <head><style> inside <head>style="" attribute directly on an elementThis lesson covers #3.
style Attributeproperty: value;<p style="color: #333; font-size: 18px; line-height: 1.6;">
This paragraph has inline styles applied directly.
</p>
Text styling:
<h1 style="color: #b7142e; font-size: 2rem; font-weight: 800;">
Headline
</h1>
Background and spacing:
<div style="background: #f5f5f0; padding: 1.5rem; border-radius: 8px;">
A styled container
</div>
Border:
<blockquote style="border-left: 4px solid #006ba6; padding-left: 1rem; margin-left: 0;">
A pull quote or testimonial
</blockquote>
Inline code look:
<span style="font-family: monospace; background: #eee; padding: 2px 6px; border-radius: 3px;">
inline code
</span>
!important)<!-- Even if an external stylesheet says h2 { color: blue; },
this h2 will be red — inline styles always win. -->
<h2 style="color: red;">This heading is always red</h2>
Here’s a short poem styled with inline styles only:
<article>
<h1 style="font-size: 1.5rem; font-weight: 700; letter-spacing: 0.02em;">
Inventory
</h1>
<p style="font-style: italic; color: #555; margin-bottom: 0.25rem;">
Four chairs, one table.
</p>
<p style="font-style: italic; color: #555; margin-bottom: 0.25rem;">
A lamp that flickers in the wind.
</p>
<p style="font-style: italic; color: #555;">
Everything I own fits in a van.
</p>
<p style="font-size: 12px; color: #999; margin-top: 1.5rem;">
— K.L.W.
</p>
</article>
—color-text or —spacing-md — that live in a stylesheet