Computer >> Computer tutorials >  >> Programming >> CSS

Selects all elements with class=mydemo with CSS


To select all elements with class=”mydemo”, you can try to run the following code. Use the .class CSS selector to achieve this,

Example

<!DOCTYPE html>
<html>
   <head>
      <style>
         .demo {
            border: 2px dashed orange;
         }
      </style>
   </head>
   <body>
      <h1 class = "demo">Heading 1</h1>
      <h1>Heading 1</h1>
      <h2>Heading 2</h2>
   </body>
</html>