KoderSolutionKoderSolution LogoKoderSolution Logo
HomeArticlesTutorialsToolsRun CodeForumAI Lab
🎨

CSS

Topic Hub & Articles

CSS Introduction

10 min

CSS Syntax

10 min

CSS Selectors

10 min

Recap Quiz

Gated

Milestone Assessment

CSS How To

10 min

CSS Comments

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Colors

10 min

CSS Backgrounds

10 min

CSS Borders

10 min

CSS Margins

10 min

CSS Padding

10 min

CSS Height/Width

10 min

CSS Box Model

10 min

CSS Outline

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Text

10 min

CSS Fonts

10 min

CSS Icons

10 min

CSS Links

10 min

CSS Lists

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Tables

10 min

CSS Display

10 min

CSS Max-width

10 min

CSS Position

10 min

CSS Overflow

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Float

10 min

CSS Inline-block

10 min

CSS Align

10 min

CSS Combinators

10 min

CSS Pseudo-class

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Pseudo-element

10 min

CSS Opacity

10 min

CSS Navigation Bar

10 min

CSS Dropdowns

10 min

CSS Image Gallery

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Attribute Selectors

10 min

CSS Rounded Corners

10 min

CSS Gradients

10 min

CSS Shadows

10 min

CSS 2D Transforms

10 min

CSS 3D Transforms

10 min

CSS Transitions

10 min

CSS Animations

10 min

CSS Tooltips

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Images

10 min

CSS Flexbox

10 min

Recap Quiz

Gated

Milestone Assessment

CSS Grid

10 min

CSS Media Queries

10 min

Progress
0%

0 / 46 Lessons

KoderSolutionKoderSolution LogoKoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Facebook PageX (Twitter) ProfileYouTube ChannelContact Support

Engineering Newsletter

Subscribe for weekly software engineering tutorials, architecture guides, and developer tool updates.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
CSSCSS Tutorial
Lesson

CSS Colors

10 min reading
Free Course

CSS Colors: Hex, RGB, HSL, and Opacity Formats

CSS colors control text ink (color), background fills (background-color), borders (border-color), and shadows across web interfaces. Modern CSS supports 140 named colors along with Hexadecimal, RGB, and HSL notations—each suited to different design workflows.

Comparing CSS Color Models

  • Hex (#38bdf8 or #fff): Compact six-digit (or three-digit shorthand) RGB values, plus eight-digit hex (#2563eb80) for alpha transparency.
  • RGB / RGBA (rgb(37 99 235 / 0.85)): Sets Red, Green, and Blue intensity (0–255) with optional alpha opacity (0 to 1 or percentage).
  • HSL / HSLA (hsl(221 83% 53%)): Uses Hue (0–360 degrees), Saturation (0%–100%), and Lightness (0%–100%). HSL makes darkening a hover button effortless by lowering Lightness by 8%.
  • currentColor: Keyword that inherits the element's active color value for matching borders or SVG icon fills.
:root {
    --brand-hue: 221;
    --brand-primary: hsl(var(--brand-hue) 83% 53%);
    --brand-hover: hsl(var(--brand-hue) 83% 45%);
}

.btn-primary {
    background-color: var(--brand-primary);
    color: #ffffff;
    border: 2px solid transparent;
    padding: 10px 18px;
}

.btn-primary:hover {
    background-color: var(--brand-hover);
}

.badge-soft {
    background-color: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
    border: 1px solid currentColor;
}

Contrast and Accessibility

Always verify foreground-to-background contrast ratios using browser DevTools. Aim for at least 4.5:1 for body text and 3:1 for large headings or UI borders so low-vision users read comfortably.

Common Mistakes to Avoid

  • Using CSS opacity when you only want a transparent background: opacity: 0.5 fades child text and icons too; use rgba(), hsla(), or rgb(... / 0.5) instead.
  • Hardcoding hex shades everywhere: Store palette values in :root CSS custom properties so dark mode and rebranding take minutes.
  • Ignoring focus and hover state contrast: Ensure button text stays crisp during :hover and :disabled states.

Frequently Asked Questions

What is the modern space-separated syntax in rgb() and hsl()?

Modern CSS Color Level 4 lets you omit commas and add alpha after a slash, like rgb(15 23 42 / 90%) or hsl(217 91% 60% / 0.2).

How does currentColor save CSS code?

Setting border: 1px solid currentColor; or fill: currentColor; on an inline SVG automatically syncs its border or icon color whenever the parent's text color changes.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground

Related Developer Tools & Topic Hub

CSS Topic Hub
HTML Formatter
Beautify and inspect HTML markup
CSS Formatter
Clean and format stylesheets
PX to REM Converter
Calculate responsive CSS units
All CSS Articles
Deep-dive guides, tips & discussions
PreviousCSS Comments
Continue JourneyNext: CSS Backgrounds

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum