Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selectors in CSS3
#1
Example:

<!DOCTYPE html>
<html>
<head>
  <title>Selectors Example</title>
  <style>
    /* Select the paragraph elements and apply a red text color */
    p {
      color: red;
    }
   
    /* Select all elements with the class "highlight" and apply a yellow background color */
    .highlight {
      background-color: yellow;
    }
  </style>
</head>
<body>
  <p>This is a paragraph with red text color.</p>
  <p class="highlight">This is a highlighted paragraph with a yellow background.</p>
</body>
</html>

Explanation:

CSS selectors are used to target specific HTML elements for styling. In this example, we use two types of selectors: the element selector (p) targets all p elements and applies a red text color to them. The class selector (.highlight) targets all elements with the class "highlight" and applies a yellow background color.
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
  Sibling selectors in CSS3 Qomplainerz 0 264 07-26-2023, 07:17 PM
Last Post: Qomplainerz
  Child selectors in CSS3 Qomplainerz 0 255 07-26-2023, 07:16 PM
Last Post: Qomplainerz
  Attribute selectors in CSS3 Qomplainerz 0 279 07-26-2023, 07:12 PM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 1 Guest(s)