Example 1 — Hex Background
Fill a box with a six-digit hex color and white text.
<style>
div {
background-color: #2563eb;
color: #fff;
padding: 16px;
}
</style>
<div>Solid background</div> How It Works
- Pick a hex value.
#2563ebis a six-digit RGB hex (blue). - Paint the box.
background-colorfills the border box by default. - Set the text separately.
color: #fffkeeps the words readable on the blue fill. - Not inherited. Nested elements do not get this blue unless you set it again or use
inherit.

