Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchTo change the color of an HTML heading, use CSS: set color for its text and background-color for the element’s background. If by “header” you mean the semantic <header> container, style that separately; it is not the same element as an <h1> heading.
You can also style a heading’s border, underline, shadow, or outline with other CSS properties. The right selector depends on whether you want to change every heading, one heading, or the surrounding header container.
Header versus heading: choose the right element
The HTML <header> element is a container for introductory or navigational content, such as a logo, links, or headings. The <h1> through <h6> elements represent headings in the document. A header can contain a heading, but styling header does not automatically select every heading on the page.
For example, style all level-one headings with h1, one reusable heading with a class such as .page-title, or a page header container with .site-header. Use heading elements to express document structure, not just to get a particular default font size.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
CSS properties for heading color and decoration
| What you want to change | CSS property | Example |
|---|---|---|
| Heading text | color | h1 { color: #1f2937; } |
| Heading background box | background-color | h1 { background-color: #2563eb; } |
| Border | border-color, with a border style and width | h1 { border: 3px solid #2563eb; } |
| Underline or other text decoration | text-decoration-color | h1 { text-decoration-color: #f97316; } |
| Text shadow | text-shadow | h1 { text-shadow: 2px 2px 4px #000; } |
| Outline | outline-color, with an outline style and width | h1 { outline: 2px solid #f97316; } |
color changes the foreground text, while background-color fills the element’s background box. A border color alone does not create a visible border: set a border style and width too. An outline is drawn outside the border and is often used for focus indicators.
Style a heading and its header container
Use separate selectors when the container and heading need different colors. For example, the CSS rule .site-header { background-color: #0f172a; padding: 1.5rem; } sets the container background, while .site-title { color: #f8fafc; } sets the heading text color.
You can add a colored underline and shadow to the heading with declarations such as text-decoration-line: underline, text-decoration-color: #38bdf8, and text-shadow: 1px 1px 2px rgb(0 0 0 / 40%). A shadow does not replace the text’s actual color.
Rank #2
For all headings, use a grouped selector such as h1, h2 { color: #123b66; }. To style only one heading, add a class such as .page-title { color: rebeccapurple; }. A class is generally preferable when the style may be reused.
Ways to add the CSS
Inline CSS
For a quick test or one-off element, place declarations in the element’s style attribute, for example: <h1 style=”color: crimson; background-color: #fff1f2;”>Page title</h1>. Inline styles can be difficult to maintain and can take precedence over ordinary stylesheet declarations.
Internal stylesheet
For a small or self-contained page, put a CSS rule in a <style> block inside the document’s <head>.
Rank #3
External stylesheet
For a multi-page site, put the rule in a CSS file and load it with a stylesheet link, such as <link rel=”stylesheet” href=”styles.css”>. This is generally easier to maintain across pages.
Why a heading color may not appear
- Check the selector. Confirm whether you are styling the heading, the <header> container, a link inside the heading, or a different element.
- Check the declaration and stylesheet. Make sure the property and value are valid and that the stylesheet path is correct.
- Check competing rules. A more specific selector, an inline style, or a later declaration may win in the CSS cascade.
- Check inheritance and links. The color property is inherited, but a heading or link with its own color rule can override the inherited value.
- Inspect computed styles. Browser developer tools show which declaration is active and which declarations are overridden.
For example, a rule for header targets the semantic container, while h1 targets level-one headings. To target a heading inside a header, use a selector such as header h1.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use current CSS color values
CSS color properties accept values such as named colors, hexadecimal colors, rgb(), hsl(), and hwb(). These formats can also represent transparency where supported by the syntax. A gradient is an image, not a color value for color; use a background property if you want a gradient effect.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Use readable colors
Check that text remains readable against its actual background. The W3C’s WCAG 2.2 Success Criterion 1.4.3 sets a minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text at Level AA. Do not rely on color alone to communicate meaning; add text or another visual cue where needed.
Test headings, links, and focus states separately. If a background image has changing brightness, use a solid backing color, overlay, or other treatment that preserves legibility.
Outdated color attributes
Do not use obsolete presentational approaches such as the <font color=”red”> element, a color attribute on <h1>, or bgcolor on an element. Use CSS properties such as color and background-color instead.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsBest Value
FAQ
How do I change the text color of an HTML heading?
Use CSS color, for example: h1 { color: #123b66; }. Use a class selector if you want to style just one heading.
How do I change an HTML heading’s background?
Use background-color on the heading element. It colors the element’s background box, not just the text glyphs.
Is <header> the same as <h1>?
No. <header> is a semantic container, while <h1> through <h6> are heading elements. A header may contain a heading.
How can I change only the underline or border color?
Use text-decoration-color for a text decoration. For a border, set a border style and width as well as its color; border-color alone does not create a visible border.
Why does my heading ignore the CSS color rule?
The selector may target a different element, the stylesheet may not be loaded, or another declaration may win in the cascade. Inspect the heading’s computed styles in browser developer tools.
The Bottom Line
Use CSS to style headings and header containers. Set color for heading text and background-color for its background; use properties such as border-color, text-decoration-color, text-shadow, and outline-color for additional effects. Choose a selector that targets the intended element, then check the cascade and text contrast.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

