CodeSolved

A comprehensive source of programming questions and exercises

Select an element with class

Practice Easy 189/ Download 296 Views

CSS code to select all the following elements at once and change their background color to yellow


<div id = "box" class = "yellow"> </V>
<div class = "yellow"> </V>
<div class = "yellow mybox"> </V>

7 Answers

<!DOCTYPE html>
<html dir="rtl">
<head>
   <meta charset="UTF-8">
   <meta name="viewport"content="width=device.width, initial-scale=1.0">
  <title> رنگ</title>
  </head>
  <style>
    div{
      background-color: yellow
    }
  </style>
<body>
  <div id="box" class="yellow">رضا</div>
  <div class="yellow">هادی</div>
  <div class="yellow mybox">هوشنگ</div> 
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box , .yellow , .mybox {
            background-color: yellow;
            width: 100px;
            height: 100px;
            border-radius: 15px;
            margin: 10px;
        }
    </style>
</head>
<body>
    <div id="box" class="yellow"></div>
    <div class="yellow"></div>
    <div class="yellow mybox"></div>
</body>
</html>
#box,
.yellow {
    background-color: yellow; # Background color change to yellow
}
Mma123 Download HTML & CSS
<!DOCTYPE html>
<html>
  <head>
    <style>
      div.yellow{
        background-color: yellow;
      }
    </style>
  </head>
  <body>
    <div id="box" class="yellow">hello</div>
    <div class="yellow">im</div>
    <div class="yellow mybox">RezaNajafiane</div>
  </body>
</html>

Saying using Class Rezanajafianez


Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close