×

CSS Color Keywords

Here, we will discuss the following keywords:
transparent
currentcolor
Inherit

Transparent keyword

  • A color can generally be made transparent by using the transparent keyword. Often it is used to for all intents and purposes make a transparent background color for an element.
  • We basically have here kind of transparent background colors for the <div> element and transparent background images for the background images.
  • HTML elements can be made kind of transparent using CSS's the particularly transparent keyword. This can essentially be used, for example, to set transparent background in really big way. The transparent keyword can for the most part be used wherever a color value specifically is accepted.
  •  The transparent keyword is equivalent to rgba(0,0,0,0), particularly contrary to popular belief. In addition to RGB color values, RGB color values specifically include a really alpha channel - which specifies the opacity for a pretty particular color, which mostly is fairly significant.
  • In some cases, you do generally have to expressly set the foundation to straightforward in a major way. For instance, you should set a component to straightforward assuming its experience tone is presently misty shading.

Syntax

background-color: transparent;

Example

Code is as follows:

<!DOCTYPE html>
<html>
<head>
<style>
body {
 /* background-image: url("paper.gif"); (you can insert any img in it)*/
}


div.ex1 { 
  background-color: lavenderblush;
  border: 4px solid black;
  padding: 18px;
}


div.ex2 { 
  background-color: transparent;
  border: 4px solid black;
  padding: 18px;
} 
</style>
</head>
<body>


<h2>The transparent Keyword in CSS</h2>


<div class="ex1">This has a lavenderblush background.</div>
<br>
<div class="ex2">Transparent background is shown here....</div>


</body>
</html>

The output of the above code:

CSS Color Keywords

Current color keyword

  • CSS currentcolor is used to for the most part define the color while using the color property.
  • You can easily use currentcolor keyword if you mostly want a particular color to for all intents and purposes appear at definitely multiple places.
  • After setting the color property, you can quickly use currentcolor to set it for all very other places where the color should essentially be set in a subtle way.
  • If you specifically want to change all the colors in the future, you have to generally make the changes in one place.
  • Browsers supported-CSS currentcolor keyword is supported by the following listed browsers:
    # Chrome
    # Firefox
    # Safari
    # Opera
    # Internet Explorer

Syntax

background-color: currentcolor ;

We will essentially see two examples for currentcolor. In the first example, we will use the currentcolor for box-shadow and in the second example we will use currentcolor for the text color on backgrounds.

Example 1

This example will show currentcolor for box-shadow.

Code is as follows:

<!DOCTYPE html>
<html>
<head>
    <title>
        CSS currentcolor keyword
    </title>
    <style>
        body {
            color: rgb(233, 84, 84);
            font-size: 1.2em;
        }
          
        div {
            box-shadow: 0px 0px 80px currentcolor;
            border: 11px solid;
            width: 40%;
            margin: auto;
            padding: 22px;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>Javatpoint</h1>
  
        <div>
            This is the interview questions Portal
        </div>
    </center>
</body>
</html>

The output of the above code:

CSS Color Keywords

Example 2

This example will show currentcolor for the text color on backgrounds.

Code is as follows:

<!DOCTYPE html>
<html>
<title>CSS currentcolor keyword</title>
  
<head>
    <style>
        body {
            color: rgb(155, 67, 67);
        }
          
        div {
            background: currentcolor;
            width: 40%;
            margin: auto;
            padding: 5px 18px;
        }
          
        div > p {
            color: white;
            opacity: 0.5;
            font-size: 1.5em;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>Javatpoint</h1>
        <div>
            <p>This is the interview questions Portal</p>
        </div>
    </center>
</body>
</html>

The output of the above code:

CSS Color Keywords

Inherit keyword

  • A property can specifically inherit its value from its parent element.
  • Any CSS property, or any HTML element, can for all intents and purposes be modified with the inherit keyword.

Syntax

border: inherit ;

The below example actually shows how the border settings for the span element will be inherited from its parent element:

Example

Code is as follows:

<!DOCTYPE html>
<html>
<head>
<style>
div {
  border: 2px solid palevioletred;
}


span {
  border: inherit;
}
</style>
</head>
<body>


<h2>The inherit Keyword</h2>


<div>Similarly, the <span>span element's</span> border settings will be inherited from the parent element.</div>
<br>


<div style="border:2px dotted blueviolet;">In this , the border settings of the <span>span element's</span> child element will also be inherited from the parent element.</div>


</body>
</html>

The output of the above code:

CSS Color Keywords

Related Topics

CSS Functions

CSS functions are used for different CSS properties. Every front-end developer should have knowledge of all CSS functions. It makes the coding easier. FunctionsExplanationattr().It returns the value of an attribute of...

5 minutes read.

CSS Math Functions

The CSS math functions permit numerical articulations. These CSS math functions can particularly be utilized in maybe unforeseen ways, for example, inside angles and shading the functions and in the...

3 minutes read.

CSS Word Wrap

Word Wrap in CSS: The word-wrap property in CSS is referred to break any lengthy word and wrap towards the next or following line. It is employed for preventing overflow...

1 minute read.

CSS Outline

CSS Outline: This CSS property is quite similar to the border property of CSS. It eases us to design an additional border around the element to obtain visual attention. The...

4 minutes read.

CSS: nth-selector

CSS nth selector can be used to match an element according to its position regardless of its parent’s type. Here, n can be any number, formula, or a keyword. These selectors...

2 minutes read.

CSS Syntax

The CSS syntax contains the selector and the declaration block, which will be clearer with the following example: Selector: A CSS selector specifies the HTML tag we wish to style. A selector can be...

2 minutes read.

CSS :root selector

CSS :root selector This CSS pseudo-class matches any document’s root element. It chooses the parent of the highest-level inside the document DOM or tree. An element of <html> is always a...

2 minutes read.

CSS Lists

CSS Lists: Several properties are available in CSS that are used to manage the lists. Lists are distributed as ordered and unordered kind of lists. The ordered lists provide the...

7 minutes read.

How to change font size in CSS

How to change font size in CSS? Font Size: - Users may attract attention to content on a website page in various ways. One element in a sentence can be highlighted. You...

5 minutes read.

CSS User Interface

Introduction User Interface can be defined as series of visual elements like screens, buttons, forms that help the user interact with the software application or hardware device. CSS User Interface allows the...

6 minutes read.

Divi in CSS

Divi is popular WordPress themes due to its versatility and user-friendly interface. It includes a built-in page builder for sophisticated design options and an assortment of customization features to help...

9 minutes read.

CSS @keyframes rule

CSS @keyframes rule It describes the rule of animation that depicts the properties of CSS for the components at every state along with the timeline. We may make the properties of complex...

4 minutes read.

How to use google fonts in CSS

Fonts: - Fonts are used to make our website look more beautiful. Choosing appropriate font according to the web design or layout is also important. Many typefaces are accessible in...

4 minutes read.

How to edit CSS in WordPress

Developing a new website or blog is a difficult undertaking. We want to create something that the consumers will adore, but we might not want the setting to take months and...

7 minutes read.

Internal CSS

What is CSS? CSS stands for Cascading Style Sheet.CSS is used to apply styling the HTML elements.With CSS user can add or change color, font-size and font-family. It also helps user...

4 minutes read.

CSS Background-blend-mode

Background-blend-mode The background-blend-mode property sets a blend mode of the component’s every background layer (color/image). It illustrates how the element background image blends well with the element background color. We can...

9 minutes read.

CSS Letter-spacing

CSS Letter-spacing: Letter-spacing attribute is applied to manage the space among all letters within the block or element of the text. This property sets the behavior of the spacing between...

2 minutes read.

CSS Border

CSS Border: The border property of CSS allows us to define the style, color, width, and radius of the element’s border. It is applied to various elements to set-up the...

4 minutes read.

CSS Navigation bar

CSS Navigation bar: A navigation system or navigation bar comes upon GUI that can help many visitors to access the information. A Navigation bar is a UI component on the...

11 minutes read.

CSS Dropdowns

Dropdowns are one of the maximum crucial parts of an interactive internet site. CSS is a kind used to design the drop-down menus. A drop-down essentially is a group of...

5 minutes read.