back

</>CodeWithRahul

More
  • Home
  • Cources
  • Tutorials
  • Tutorials
  • Projects
  • Notes
  • Contact
  • Work With Us
  • HTML
  • CSS
  • JAVASCRIPT
  • CC++
  • PHP
  • PYTHON
  • REACT JS
  • DSA

</>Code With Rahul

Create an account
  • INTRODUCTION
    • Information & History
    • Your first CSS Website
    • How CSS Works?
    • Ways to add CSS
    • CSS Selectors
    • CSS Comments
  • CSS Properties
    • CSS colors
    • CSS backgrounds
    • CSS Borders
    • CSS Image
    • CSS Videos Embedding
    • CSS Fonts
    • CSS Text Styling
    • CSS Padding
    • CSS Margin
    • CSS Hover
    • CSS Links
    • CSS Combinators
    • CSS Pseudo Classes
    • CSS Buttons
    • CSS Overflow
    • CSS Float
    • CSS !Important
    • CSS Maths Function
    • CSS Size
    • CSS Positioning
    • CSS Z-index
    • CSS Forms
    • CSS Navigation
  • CSS Designing
    • CSS Display
    • CSS FlexBox
    • CSS Grid
    • CSS Meida Queries
  • CSS Advance Topics
    • CSS CSS 2D
    • CSS Transform
    • CSS Transition
    • CSS Border Image
    • CSS Gradients
    • CSS Inherit
    • CSS Shadows
    • CSS ToolTip Text
    • CSS Border Image
    • CSS Masking
    • CSS Pagination
    • CSS Meida Queries Advance
    • CSS Animation
  • CSS FAGS
    • CSS Questions

    CSS Colors

    We have been glimpsing this property for quite a while in the Introduction portion; so you must be aware that this property can help us set the colour of the text.

    <style>
        h1 {
            color: value;
        }
    </style>
    

    Now there are many ways of giving this value to the colour. Some of the most common are listed below.

    1. RGB format:

    The full form of RGB is “Red, Green, Blue” and thus it defines the colour value by taking three arguments ranging from 0 to 255.
    Syntax: {color: rgb(0,0,0);}.

    Note that this colour is black, if you change each of the values to 255 white colours of the text would be selected.

    Here’s an example to give you clarity on the RGB colour scheme.

    CSS_Color_property

    The output of this would be-

    CSS_Color_property_Result

    1. Hexadecimal notation :

    By using the hex code of any colour you can assign that colour to the element.

    For Example :-

    <style>
        h1 {
            color: #2D1F53;
        }
    </style>
                                

    This way you can give specific values to the colour by searching for their hex codes on google.

    3. HSL:

    HSL stands for Hue, Saturation and Lightness. Tweaking these values gives different colours, and the syntax is quite similar to RGB.

    For Example :-

    <style>
        /* h5 {
            color : hsl(hue, Saturation, Lightness);
        } */
        h5 {
            color: hsl(198, 84%, 45%);
        }
    </style>
                                

    Hue refers to the dominant colour family present in that colour, saturation adds the shades to that dominant colour and lastly, lightness describes the transparency and boldness of that colour.

    Apart from these methods RGBA and HSLA too are used to give colour to text, but that is something not so common with beginners.

    Owner of this WebPage Image

    CodeWithRahul

    Copyright © 2023 CodeWithRahul.com