CSS Introduction

CSS Tutorial What is CSS CSS Syntax CSS Selector How to include CSS CSS Comments

CSS Attributes

CSS Background CSS Border CSS Display CSS Float CSS Font CSS Color CSS Hover CSS Important CSS Line-height CSS Margin CSS Opacity CSS Filter CSS Images CSS Overflow CSS Padding CSS Position CSS Vertical align CSS White space CSS Width Word-wrap in CSS Box-shadow in CSS Text-transform in CSS CSS Outline CSS Visibility CSS Counters CSS Clear fix CSS Icons CSS Justify-content Text-decoration in CSS CSS Lists CSS nth selector CSS Sticky CSS Background-clip CSS Checkbox-style CSS Letter-spacing CSS Navigation bar CSS Overlay CSS Root CSS Specificity CSS Text-indent CSS Text-stroke CSS Zoom CSS Order CSS Descendent selector CSS Clip CSS calc() CSS Background-blend-mode CSS radio-button CSS Superscript and subscript CSS Text-effects CSS Text-align CSS Variables CSS Page-break-before CSS Page-break-inside CSS Page-break-after CSS Content property CSS Word-spacing CSS Animation CSS @keyframes rules CSS Pseudo-classes CSS Pseudo-elements CSS Radial-gradient CSS Translate CSS Gradients CSS z-index CSS Loaders CSS Units CSS Transition CSS Masking CSS Arrow CSS Pagination Font-Face in CSS CSS Two Classes CSS Type Not Equal CSS Display Grid CSS Fade Animation CSS Grid CSS Color Code CSS Selects All Children CSS Shapes CSS Stylesheet or Cheatsheet Button Disabled CSS Contact Form in HTML and CSS CSS Abbreviation CSS Align to the Bottom CSS Animation Fade-in CSS Margin vs Padding CSS Media Print CSS Tilde CSS Beautifier CSS Multiple Classes CSS Normalization CSS Not First Child CSS Portal CSS Pseudo Classes How to Make Align the Right Elements in CSS Image and Text Side by Side in CSS Root in CSS Free CSS com

Questions

What is Bootstrap CSS What is CSS used for How to center a table in CSS What is a CSS File How to center a button in CSS How to change background color in CSS How to change the font in CSS How to change font size in CSS How to resize an image in CSS How to get rid of bullet pioints in CSS Is CSS a programming language How to edit CSS in WordPress How to use google fonts in CSS How to create blinking text using CSS How to Set Space between the Flexbox Is CSS a Programming Language

Difference

Difference between HTML and CSS Grid Vs Flexbox in CSS Difference between CSS Grid and CSS Flexbox

Misc

Create a 3D text effect using HTML and CSS Hover condition for a:before and a:after in CSS Bem CSS Boder Types CSS Features of CSS Font Face CSS Image Overlay CSS CSS Responsive Design CSS Responsive Design CSS Scrollbar CSS Transform Code for Blue in CSS How to create circle in CSS? How to download font family? Box Model in CSS with Example CSS Background Image CSS Login CSS Object-Fit CSS Placeholder Color CSS Slider HTML CSS Projects Link CSS MDN CSS Movate CSS Crop CSS Font Shorthand How to Write CSS Responsive Code Live HTML CSS Code Editor Opacity CSS SCSS TO CSS

CSS Stylesheet or Cheatsheet

Cascading style sheets describe the web page in a markup language like HTML, XML, etc. CSS properties describe the item or function displayed on the screen or in different media. CSS improves the webpage's appearance and feel of interactive functions.

CSS's most popular style properties are gradient, background, button, radius, box, font family, order, and text-shadow generators. The CSS Cheat Sheet provides additional tools to enhance the visual impact of your work. You can find all these and other helpful web design tools on one website.

CSS Fundamentals

The Cascading Style Sheets or CSS are used to style web pages that contain HTML components. In this section, we will look at the three distinct methods we can use to add CSS to our HTML page over steps one by one.

1. Internal CSS:

  • The following syntax is used to apply the internal CSS style sheet in the head section.
  • The internal CSS is used to apply design using the style tag in the HTML page.
    <head>

    <style>

    Element{

    Property: value;

    Property: value;

    ….

    }

    </style>

    </head>

    2. Inline CSS:

    • The inline CSS is used to apply design using a style tag in the HTML tag or element.

    • The following syntax is used to apply the inline CSS style sheet in the HTML tag.
    <tag style = "property: value; property:value;">

    3. External CSS:

    • The external CSS file is created using the CSS file name with the.css extension.

    File_name: style_demo.css

    • It contains the single or multiple properties in the file.
    Selector{

    Property: value;

    Property: value;

    ….

    }
    • The external CSS files are included in the head section of the HTML page.
    <link rel="stylesheet" type="text/css" href="/style_demo.css" />

    4. Clearfix:

    • : It clears floats to operate and control margins and padding.
      .clearfix_element::after {

          content: "";

          clear: both;

          display: block;

      }

      5. Selector: Select the HTML elements to style with the element name, id, etc. These are basic selectors as follows:

      Basic SelectorsDescriptionSyntax
      UniversalIt selects all available elements on the pages.*{ property: value; }
      Element TypeIt selects the required HTML tag or element used in the document.p{ property: value; }
      IdIt selects a unique ID name of the element.#id{ property: value; }
      ClassIt selects a unique and required class name of the element..class_name{ property: value; }
      AttributeIt Selects all available elements with a specified attribute.a[attribute=value] { property: value; }
      CombinatoryIt is used for Complex selectors. It consists of more than one selector with the relationship between the selector.selector_1 selector2/ selector_1+selector2 / selector_1> selector 2 {property: value;}
      pseudoIt is used to define the special state of an element. The element adds an effect to an available element and its states.selector: pseudo-class{ property: value; }

      Example

      The following example shows the various CSS selectors with the style property. We can see all types of selectors and internal and inline CSS style tags.

      <!DOCTYPE html>

      <html>

      <head>

      <title> CSS Selectors </title>

      <!-- CSS Selectors are in use -->

      <style>

      /* CSS universal selector */

      * {

      background-color: lightblue;

      text-align: center;

      }

      /* CSS type selector */

      span {

      background-colour: navy;

      color: white;

      }

      /* CSS id selector */

      #id1 {

      color: yellow;

      text-align: center;

      font-size: 18px;

      font-weight: bold;

      }

      /* CSS class selector */

      .class2 {

      color: orange;

      text-align: center;

      font-size: 25px;

      font-style: italic;

      }

      /* CSS attribute selector */

      div[style] {

      text-align: center;

      color: purple;

      font-size: 20px;

      font-weight: bold;

      margin-bottom: -20px;

      }

      /* CSS combinator selector */

      div>p {

      color: #009900;

      font-size: 32px;

      font-weight: bold;

      margin: 0px;

      text-align: center;

      }

      /* CSS class selector */

      .boxes {

      background-color: brown;

      width: 200px;

      height: 120px;

      margin: auto;

      font-size: 20px;

      text-align: center;

      }

      /* CSS pseudo selector */

      .boxes:hover {

      background-color: orange;

      }

      </style>

      </head>

      <body>

      <p>

      Universal Selector here (*) gives a lightblue background

      </p>

      <br>

      <span>This span tag is used to style a type selector.

      <br><br>

      <div id = "id1">

      This div is used to style functions using the ID selector

      </div>

      <br>

      <div class = "class2 ">

      This div is used to style functions using a class selector

      </div>

      <br>

      <div style = "color: red;">

      This div is used to style functions using the attribute selector

      </div>

      <br>

      <div style = "text-align: center;">

      This div is used to style functions using combinators

      <p> child selector </p>

      </div>

      <br>

      <p> pseudo selector: </p>

      <div class = "boxes">

      This div is used to style function using a pseudo-selector

      The colour changes if you hover over the box!

      </div>

      </span>

      </body>

      </html>

      Output

      The output shows the selector and its design.
      CSS Stylesheet or Cheatsheet

      Font Properties

      CSS font properties are worked to set the style and design of the font's content in the HTML element according to requirements.

      PropertyDescriptionSyntax
      Font-familyWe can give the Specific font family for the context.Font-family: generic-family |initial | family-name |inherit;
      Font-styleWe can style the text in a normal, italic, or oblique style for its font family.Font-style: normal |initial |inherit |italic |oblique;
      Font-variantIt is used to Convert all lowercase letters into uppercase letters.Font-variant: normal| small caps | initial;
      Font-weightIt is used to Specify the thickness of the fontfont-weight: normal| bold |initial |inherit |unset |number;
      Font-sizeIt Specifies the size of the text in an HTML document.Font-size: small |medium |large |initial |inherit;

      Example

      The following example shows the various CSS font properties with style differences.

      <!DOCTYPE html>

      <html>

      <head>

      <title> CSS Font properties </title>

      <style>

      .demostyle1 {

      font-family: "Times New Roman", "sans-serif";

      font-weight: bold;

      font-size: 30px;

      color: #090;

      text-align: center;

      font-style: normal;

      font-variant: normal;

      }

      .demostyle2 {

      font-family: "sans-serif";

      font-weight: 5px;

      font-size: 15px;

      color: blueviolet;

      text-align: left;

      font-style: italic;

      font-variant: normal;

      }

      .demostyle3 {

      font-family: "arial";

      font-weight: 10px;

      font-size: 20px;

      color: black;

      text-align: right;

      font-style: oblique;

      font-variant: small-caps;

      }

      div{

      width : 300px;

      border: 1px solid black;

      background-color: aqua;

      }

      </style>

      </head>

      <body>

      <div>

      <h3> CSS Font properties </h3>

      <p> Regular text is used to align centre-sized 10 px </p>

      <div class = "demostyle1"> Javatpoint Learning portal </div>

      <p> Italic text and aligned left is used with 15px font size </p>

      <div class = "demostyle2"> Javatpoint Learning portal </div>

      <p> Oblique text and aligned right is used with 20px font size using in small caps </p>

      <div class = "demostyle3"> Javatpoint Learning portal </div>

      </div>

      </body>

      </html>

      Output

      The output shows the font property on the text.
      CSS Stylesheet or Cheatsheet

      Text-properties

      The CSS text formatting properties are used to format and style text. It is used for setting their colour, alignment, spacing, and others according to requirements.

      PropertyDescriptionSyntax
      text-colorIt is used to set the colour of the text.color: color_value;
      text-alignmentIt works to get the horizontal alignment of the text.Text-align: left|right|center| justify|initial|inherit;
      text-decorationThis property is worked to Add or remove text- decorations.Text-decoration: decoration-type;
      text-transformChanges the text case such as uppercase.Text-transform: none|capitalize|uppercase| lowercase|initial|inherit;
      text-indentIndents the first line of text function.Text-indent: length|initial|inherit;
      letter-spacingGives spacing between the letters of the text.Letter-spacing: normal|length| initial|inherit;
      line-heightProvides the space between the text lines.Line-height: normal|number|length| percentage|initial|inherit;
      text-shadowProvides shadow to the text.Text-shadow: h-shadow v-shadow blur-radius color|none|initial|inherit
      word-spacingProvides space between words and lines.Word-spacing: normal|length| initial|inherit;

      Example

      The following example shows text properties for different types of text design.

      <!DOCTYPE html>

      <html>

      <head>

      <title> CSS Text formatting properties </title>

      </head>

      <body>

      <h3> CSS Text formatting properties </h3>

      <div style = "background-color:aqua; width:300px;">

      <div style = " color: red">

      CSS Color property

      </div>

      <br>

      <div style = " text-align: center">

      CSS Text align property

      </div>

      <br>

      <div style = " text-decoration: underline">

      CSS Text decoration property

      </div>

      <br>

      <div style = "text-transform: lowercase">

      CSS Text transform property

      </div>

      <br>

      <div style = "text-indent: 70px">

      CSS Text indent property

      </div>

      <br>

      <div style = " letter-spacing: 3px">

      CSS Text line spacing property

      </div>

      <br>

      <div style = "line-height: 35px">

      CSS Text line-height property

      </div>

      <br>

      <div style = "text-shadow: 4px 2px blue;">

      CSS Text shadow property

      </div>

      <br>

      <div style = "word-spacing: 10px;">

      CSS Text word spacing property

      </div>

      </div>

      </body>

      </html>

      Output

      The output shows the text property on the information.
      CSS Stylesheet or Cheatsheet

      Background Properties

      The CSS background properties are worked to design the background of the function, text, and other elements. It defines the background effects for elements.

      PropertyDescriptionSyntax
      Background-colorspecifies an element's background colour.background-color: color_name;
      Background-imageIt gives an element one or more backdrop pictures.Background-image: url(‘url’);
      Background-repeatBoth vertically and horizontally, add or delete background image repetition.Background-repeat: repeat|repeat-x|repeat-y| no-repeat|initial|inherit;
      Background-positionIt describes the specific way in which the image is positioned.Background-position: value;
      Background-originIt is utilised for modifying the webpage's background picture.Background-origin: padding-box |border-box |content-box | initial| inherit;
      Background-attachmentDescribe the background image's type of attachment within its container </td>background-attachment: scroll|fixed|local|initial|inherit;
      Background-clipIt indicates the desired background length (colour or picture).Background-clip: border-box|padding-box|content-box|initial|inherit;

      Example

      The following example shows the CSS background property and its output.

      <!DOCTYPE html>

      <html>

      <head>

      <title> CSS Background Properties </title>

      <style>

      body{

      background:aqua;

      }

      .a {

      background-image:

      url(

      "https://static.javatpoint.com/images/logo/jtp_logo.png");

      }

      .b {

      background-image:

      url(

      "https://static.javatpoint.com/images/logo/jtp_logo.png");

      background-repeat: no-repeat;

      }

      .c {

      background-image:

      url(

      "https://static.javatpoint.com/images/logo/jtp_logo.png");

      background-repeat: no-repeat;

      background-position: center;

      }

      .d {

      background-image:

      url(

      'https://static.javatpoint.com/images/logo/jtp_logo.png');

      background-repeat: no-repeat;

      background-origin: initial;

      }

      .e {

      background-image:

      url(

      "https://static.javatpoint.com/images/logo/jtp_logo.png");

      background-position: center;

      background-repeat: no-repeat;

      background-attachment: fixed;

      }

      </style>

      </head>

      <body>

      <div style  = "background-color: red"> CSS Background color property </div>

      </br>

      <div class  = "a" style  = "height: 100px; width: 100%">

      <h3>  CSS Background Image property </h3>

      </div>

      <br>  <br>

      <h3>  CSS Background repeat property: no-repeat </h3>

      <div class  = "b" style  = "height: 50px; width: 100%">

      </div>

      <br>  <br>

      <div class  = "c" style  = "height: 50px; width: 100%">

      <h3>  Background position property </h3>

      </div>

      <br>  <br>

      <div class  = "d" style  = "height: 100px; width: 100%">

      <h3> CSS Background origin property

      It is used to set the origin of the image in the background.

      </h3>

      </div>

      <br>  <br>

      <div class  = "e" style  = "height: 400px;

      width: 100%;

      text-align:center;">

      <h3>  CSS Background-attachment property </h3>

      <p> The background-attachment property is used to get the attachment of the background image using CSS. It is used to set the scroll or remain fixed.

      </p>

      </div>

      <br>

      </body>

      </html>

      Output

      The output shows the background property on the function.
      CSS Stylesheet or Cheatsheet

      Box Properties 

      The CSS box property is a box that contains the data that wraps around every HTML element. It comprises the border, padding, margin, height, width and content. The following CSS properties are used to apply style to the box model.

      PropertyDescriptionSyntax
      MarginApply to set the marginmargin: value;
      PaddingApply the space between the box border and its content using the selector.padding: value;
      BorderApply the element’s border with the width, and set the style and colour for the border.border: value;
      WidthApply the width to the box or functionwidth: value;
      HeightApply the height to the box or functionheight: value;

      Example

      The following example shows box properties for different margins, padding, and function sizes.

      <!DOCTYPE html>

      <head>

      <title>CSS Box Model</title>

      <style>

      .main {

      font-size: 18px;

      font-weight: bold;

      Text-align: left;

      margin-bottom: 20px;

      }

      .jtp {

      margin-left: 50px;

      border: 30px solid orange;

      width: 280px;

      height: 200px;

      text-align: center;

      padding: 30px;

      }

      .jtp1 {

      font-size: 42px;

      font-weight: bold;

      color: yellow;

      margin-top: 30px;

      background-color: #c0c0c0;

      }

      .jtp2 {

      font-size: 18px;

      font-weight: bold;

      background-color: #c5c5db;

      }

      </style>

      </head>

      <body>

      <div class = "main"> CSS Box-Model Property </div>

      <div class = "jtp">

      <div class = "jtp1"> JavaTpoint Learning Portal </div>

      <div class = "jtp2">

      A computer science website for a programmer

      </div>

      </div>

      </body>

      </html>

      Output

      The output shows the text property on the information.
      CSS Stylesheet or Cheatsheet

      Shadow properties

      These shadow properties are used to add a shadow on the required text border or frames of elements.

      PropertyDescriptionSyntax
      Text shadowAdd text shadow using the selector.Text-shadow: h-shadow v-shadow blur-radius color_name| none |initial | inherit;
      Box ShadowAdd a frame or box shadow using the selector.Box-shadow: h-offset v-offset blur spread color_name |none |inset |initial | inherit;

      Example

      The following example shows shadow properties for the attractive and animate function. The box-shadow property comes in different colours.

      <!DOCTYPE html>

      <html>

      <head>

      <title>  CSS box-shadow Property </title>

      <style>

      .jtp1 {

      border: 1px solid;

      padding: 8px;

      /* box-shadow: h-offset v-offset blur color*/

      box-shadow: 5px 8px 8px grey;

      }

      /* text-shadow: h-shadow v-shadow

      blur-radius color */

      h2 {

      text-shadow: 5px 5px 8px orange;

      }

      .jtp2 {

      border: 1px solid;

      padding: 5px;

      /* box-shadow: h-offset v-offset blur*/

      box-shadow: 3px 3px 5px;

      background-color: aqua;

      }

      </style>

      </head>

      <body>

      <h1>  CSS box-shadow Property </h1>

      <div class = "jtp1">

      <h3> Welcome to the javatpoint website! </h3>

      </div>

      <h2> Education portal for developer </h2>

      <div class = "jtp2">

      <h3> javatpoint website! </h3>

      </div>

      </body>

      </html>

      Output

      The output shows the shadow property on the information.
      CSS Stylesheet or Cheatsheet

      Gradient Property

      The CSS gradient property transitions between shape or size with the two or more required colours.

      GradientDescriptionSyntax
      Linear GradientIt is used to create smooth colour transitions.Background-image: linear-gradient(direction, color-1, color-2, …);
      Radial GradientIt is used to get an elliptical shape gradient.Background-image: radial-gradient(position's shape size, start-color, …, last-color);

      Example

      The following example shows the various CSS gradient properties with the style difference. The linear gradient and radial gradient are used to display the background with many colours.

      <!DOCTYPE html>

      <html>

      <head>

      <title> CSS Gradients</title>

      <style>

      #main1 {

      height: 200px;

      width: 500px;

      background-color: white;

      background-image: linear-gradient(orange, yellow, white, orange, red);

      }

      #main2 {

      height: 200px;

      width: 500px;

      background-color: white;

      background-image: radial-gradient(orange, yellow, white, orange, red);

      }

      .jtp {

      text-align: center;

      font-size: 30px;

      font-weight: bold;

      padding-top: 40px;

      }

      .jtps {

      font-size: 27px;

      text-align: center;

      }

      </style>

      </head>

      <body>

      <!-- Linear gradient property -->

      <div id = "main1">

      <div class = "jtp"> javatpoint </div>

      <div class = "jtps">

      CSS Radial Gradient

      </div>

      </div>

      <br><br>

      <!-- Radial Gradient property -->

      <div id = "main2">

      <div class = "jtp"> javatpoint </div>

      <div class = "jtps">

      CSS Radial Gradient

      </div>

      </div>

      </body>

      </html>

      Output

      The output shows the gradient properties box.
      CSS Stylesheet or Cheatsheet

      Border Properties

      The CSS border properties specify the style and size of the box's border. The following properties set the border.

      PropertyDescriptionSyntax
      Border ColorApply the colour of the border on the function. When the border-style property is used, then this property works bydefault.Border-color: color-value;
      Border StyleApply the border style like solid, double, dotted, rigged, etc.Border-style: value;
      Border WidthApply the border width of the element.Border-width: length |thick |thin |medium |initial |inherit

      Example

      The following example shows border properties for an attractive and animated function. The border uses the width, style, and color per the user's requirement.

      <!DOCTYPE html>

      <html>

      <head>

      <title>  CSS border Property </title>

      <style>

      .jtp1 {

      /* border: width style color */

      border: 4px solid blue;

      padding: 8px;

      }

      /* text-shadow: h-shadow v-shadow

      blur-radius color */

      h2 {

      border: 3px dotted navy;

      }

      .jtp2 {

      border-style: double;

      border-color: red;

      }

      </style>

      </head>

      <body>

      <h1>  CSS border Property </h1>

      <div class = "jtp1">

      <h3> Welcome to the javatpoint website! </h3>

      </div>

      <h2> Education portal for developer </h2>

      <div class = "jtp2">

      <h3> javatpoint website! </h3>

      </div>

      </body>

      </html>

      Output

      The output shows the border property on the information.
      CSS Stylesheet or Cheatsheet

      Classification Properties

      The following CSS classification properties are used to display proper elements and boxes.

      PropertyDescriptionSyntax
      DisplayIt is used to show elements on the web page.Display: inline| grid|table|group|none|block|flex| inherit;
      FloatSpecifies flow of datafloat: initial| inherit |none|left|right;
      PositionDefines the positioning of html elements on the web page.Position: fixed|relative |sticky|static|absolute;
      ClearDefines the sides of a box where floating elements are not allowed.Clear: left|right|both|none;
      VisibilityApply an element is visible or not.Visibility: visible|hidden|initial|inherit|collapse;
      CursorApply the type and shape of the cursorcursor: auto|default|pointer|crosshair|help | e-resize | all-scroll |progress |initial |inherit;

      Example

      The following example shows the classification property for the display of the box.

      <!DOCTYPE html>

      <html>

      <head>

      <title> CSS Classification properties </title>

      <style>

      #jtp1 {

      height: 30px;

      width: 100px;

      background: teal;

      display: block;

      }

      #jtp2 {

      height: 30px;

      width: 100px;

      background: cyan;

      display: block;

      }

      #jtp3 {

      height: 30px;

      width: 100px;

      background: green;

      display: block;

      }

      .pos {

      position: relative;

      left: 30px;

      border: 3px solid #73AD21;

      }

      .clr {

      width: 50px;

      height: 50px;

      background-color: red;

      color: white;

      font-weight: bold;

      font-style: itallic;

      font-size: 18px;

      text-align: center;

      float: left;

      padding: 15px;

      }

      p.GFG {

      clear: left;

      }

      h1,

      h2 {

      color: red;

      text-align: center;

      }

      .wait {

      cursor: wait;

      }

      </style>

      </head>

      <body>

      <p> CSS display Property: block  </p>

      <div>

      <div id  = "jtp1"> BOX 1  </div>

      <div id  = "jtp2"> BOX 2 </div>

      <div id  = "jtp3"> BOX 3 </div>

      </div>

      <br>

      <p> CSS Float Property:left </p>

      <div style  = "font-size:20px; color:#006400; float:right;">

      css Content floats right

      </div>

      <br>

      <p> CSS Position Property:relative </p>

      <div class  = "pos">

      The div element has a position: relative;

      </div>  <br>

      <p> CSS Clear property: left </p>

      <div class  = "clr">

      <pre> JTP </pre>

      </div>

      <p>

      Javatpoint portal:

      A computer science website for developers and coders

      </p>

      <p class  = "GFG"> Javatpoint portal </p>

      <br>

      <p> CSS Visibility property: visible/ hidden </p>

      <div style  = "visibility: visible;"> CSS Content shows visible </div>

      <div style  = "visibility: hidden"> CSS Content shows hidden </div>

      <br>

      <p> CSS Cursor property: wait </p>

      <p class  = "wait">

      Mouse over the sentence to display running the mouse cursor.

      </p>

      </body>

      </html>

      Output

      The output shows the classification property of the information.
      CSS Stylesheet or Cheatsheet

      CSS Functions 

      The CSS has a range of inbuilt functions to operate content using various CSS properties. Some of the CSS functions can be nested or simple. It ranges from simple properties to mathematical properties like shape, color, transform, gradient, and animations functions. Some of the properties  are shown below:

      FunctionDescriptionSyntax
      attr()Display the value of the selected elements' attributeattr( attribute_name );
      calc()Use a single mathematical expression to calculate the input parameter and perform operationscalc( input_Expression );
      max()Get the largest number of the given input set of numbers.max(value_1, value_2, value_3,…)
      url()Use a string URL as a parameter. It is used to load fonts, images, and data.url( <string> <url-modifier>* )
      var()Inserts the value of a custom property. Its name must start with two dashes.var( custom_property, value )

      Example

      The following example shows the attribute and function properly with the set box.

      <!DOCTYPE html>

      <html>

      <head>

      <title> CSS functions property </title>

      <style>

      a:before {

      content: attr(href) " =>";

      }

      a {

      text-decoration: none;

      }

      body {

      text-align: center;

      }

      .jtps {

      position: absolute;

      left: 50px;

      width: calc(100% - 30%);

      height: calc(100px - 30px);

      background-color: orange;

      text-align: center;

      }

      .url {

      background-image: url(

      "https://static.javatpoint.com/images/logo/jtp_logo.png");

      text-align: center;

      }

      .jtp1 {

      background-color: var(--main-bg-color);

      padding: 5px;

      }

      :root {

      --main-bg-color: yellow;

      }

      </style>

      </head>

      <body>

      <h3> CSS functions property </h3>

      <p> CSS attribute function </p>

      <a href = "https://www.javatpoint.com"> javatpoint </a>

      <br>

      <p> CSS Calc function </p>

      <div class = "jtps">

      <h3> CSS calc() Function </h3>

      </div>

      <br> <br> <br>

      <p> CSS URL function </p>

      <div class = "url" style = "height: 100px; width: 100%">

      <h3 style = "color:red;"> CSS url() function </h3>

      </div>

      <br>

      <div class = "jtp1">

      <p> CSS var function</p>

      Example of var function </div><br>

      </body>

      </html>

      Output

      The output shows the function property on the information.
      CSS Stylesheet or Cheatsheet