Colors

Color Values

Example

Colors can be written as names, HEX, RGB or HSL values. These four paragraphs use the same green:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<p style="background:mediumseagreen; color:white; padding:6px;">Color name: mediumseagreen</p>
<p style="background:#3cb371; color:white; padding:6px;">HEX: #3cb371</p>
<p style="background:rgb(60, 179, 113); color:white; padding:6px;">RGB: rgb(60, 179, 113)</p>
<p style="background:hsl(147, 50%, 47%); color:white; padding:6px;">HSL: hsl(147, 50%, 47%)</p>

</body>
</html>

Result

Transparency

Example

Add an alpha value (0 = transparent, 1 = solid) with rgba()/hsla(), or two extra HEX digits:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<div style="background:url(https://picsum.photos/id/1018/400/120); padding:16px;">
  <p style="background:rgba(0, 0, 0, 0.6); color:white; padding:8px;">Black at 60% opacity</p>
  <p style="background:#ffffffcc; padding:8px;">White at 80% opacity (#ffffffcc)</p>
</div>

</body>
</html>

Result