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

Live Demo

<!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>

Updated on: 24-Jun-2020

87 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements