Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CSS Custom properties (Variables)
#1
Example:

<!DOCTYPE html>
<html>
<head>
  <title>Custom Properties Example</title>
  <style>
    /* Define a custom property */
    :root {
      --primary-color: blue;
    }
    /* Use the custom property to apply styles */
    p {
      color: var(--primary-color);
    }
  </style>
</head>
<body>
  <p>This is a paragraph with a custom primary color.</p>
</body>
</html>

Explanation:

CSS Custom Properties, also known as CSS Variables, allow you to define reusable values. In this example, we define a custom property --primary-color with the value blue. The p element then uses this custom property to set its text color, resulting in blue text.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CSS Grid Masonry Layout Qomplainerz 0 659 07-26-2023, 07:54 PM
Last Post: Qomplainerz
  CSS Custom Scrollbar Styles (Webkit and Firefox) Qomplainerz 0 447 07-26-2023, 07:52 PM
Last Post: Qomplainerz
  CSS Box Decoration Break Qomplainerz 0 397 07-26-2023, 07:49 PM
Last Post: Qomplainerz
  CSS Conic Gradients for Circular Progress Bar Qomplainerz 0 371 07-26-2023, 07:48 PM
Last Post: Qomplainerz
  CSS Grid Subgrid Qomplainerz 0 381 07-26-2023, 07:46 PM
Last Post: Qomplainerz
  CSS Variable Fonts Animation Qomplainerz 0 383 07-26-2023, 07:44 PM
Last Post: Qomplainerz
  CSS Scrollbar Styling Qomplainerz 0 391 07-26-2023, 07:43 PM
Last Post: Qomplainerz
  CSS Grid Auto-fit and Minmax Qomplainerz 0 367 07-26-2023, 07:41 PM
Last Post: Qomplainerz
  CSS clip path Qomplainerz 0 394 07-26-2023, 07:38 PM
Last Post: Qomplainerz
  Custom font loading in CSS3 Qomplainerz 0 353 07-26-2023, 07:34 PM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 7 Guest(s)