SyntaxStudy
Sign Up
HTML Beginner 1 min read

HTML Colors

HTML Colors

Colors in HTML can be specified in several ways. They are used in inline styles, CSS, and various HTML attributes.

Color Formats

FormatExampleDescription
Color namered140+ named colors
HEX#FF00006 hex digits (RRGGBB)
RGBrgb(255,0,0)Red, Green, Blue values 0–255
RGBArgba(255,0,0,0.5)RGB + Alpha (opacity 0–1)
HSLhsl(0,100%,50%)Hue, Saturation, Lightness
💡 HEX is the most common format for web development.
Example
<p style="color: red;">Named color: red</p>
<p style="color: #6366f1;">HEX: #6366f1 (indigo)</p>
<p style="color: rgb(34, 197, 94);">RGB: rgb(34, 197, 94) (green)</p>
<p style="background-color: rgba(99, 102, 241, 0.2); padding: 8px;">
  RGBA background with 20% opacity
</p>