×

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 Box Model

Introduction The Box Model property of CSS is used for design and layout of an html page. In CSS, all the elements has a rectangular box around it, you have to...

5 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.

CSS calc()

CSS calc(): The CSS calc() function is a CSS function of inbuilt type, which permits us to implement calculations. It is used for calculating the angle, integer frequency, number, time,...

3 minutes read.

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 Float

CSS Float: The float property of CSS is the positioning property. This property is applied to elements to push them either to left or right. It permits for wrapping facility...

4 minutes read.

CSS Align

CSS Center Align Elements CSS center align is used to create align by using block element. You should specify margin: auto;properties. The element will take up the specified width and the remaining space....

2 minutes read.

CSS Content Property

Content Property The content attribute produces dynamic content. It can be applied with any pseudo-element ::after and ::before. These CSS properties are entirely supported inside every browser and applied to include...

5 minutes read.

CSS Image Gallery

Image galleries are used to display and store collections of images. Example Let’s discuss an example. CSS was used to create the following image gallery: Code is as follows: <html> <head> <style> div.gallery {   margin: 6px;   border: 1px...

5 minutes read.

CSS Clip

CSS Clip The Clip property in CSS describes the element’s visible area. It applies over the elements which are absolutely positioned (position: absolute ;). Generally, it is used when an image...

2 minutes read.

CSS Button Style

CSS button style: Using CSS properties, we can easily modify the default BUTTON and enhance its appearances using simple graphic commands. TYPES OF BUTTON STYLE: - Program to change button using CSS ...

35 minutes read.

CSS Text-Transform Property

Text-Transform in CSS The text-transform property permits us to alter the text case. It controls the capitalization of the text. This property is employed to design the text appearance in every...

3 minutes read.

CSS Loader

CSS Loader The loader is the animation that can alert a visitor regarding the loading of the page. We need to wait for some time. It will be helpful if any...

4 minutes read.

What is Bootstrap CSS?

Bootstrap: - Bootstrap is a CSS framework that is free to use and is used for the front-end development of the website in a faster and easier way. Bootstrap was released as...

3 minutes read.

How to include CSS

How to include CSS CSS is included in HTML pages for formatting the documents based on the information inside a style sheet. We can add CSS in HTML documents in the following three ways: Inline...

5 minutes read.

CSS Important

CSS Important: CSS !important property is used to provide more importance, as compared to other CSS properties. The meaning of this property is “This is important.” This property enables CSS...

2 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 Opacity

The CSS Opacity property is used to set the clarity of the image. It is defined as degree and specify the transparency of an element. Note: Opacity value will be less...

1 minute 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 Pagination

CSS Pagination The pagination in CSS is an advantageous approach for indexing of a website’s distinct pages over the homepage. When our site contains multiple pages, we must insert a few...

13 minutes read.

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.