sudhakarinfotech
(current)
Run Code
Live Code Editor- CSS Style Id & Class
Source Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Difference Between Id And Class</title> <style> /* Style the element with the id "myHeader" */ #main_heading { background-color: violet; padding: 20px; text-align: center; color: black; } /* Style all elements with the class name "city" */ .flower { background-color: orange; padding: 12px; color: black; } </style> </head> <body> <h1>Difference Between HTML ID And Class</h1> <!-- An element with a unique id --> <h2 id="main_heading">Metro City</h2> <!-- Multiple elements with same class --> <h2 class="flower">Rose</h2> <p>This is a flower of rose.</p> <h2 class="flower">Lily</h2> <p>This is a flower of lily..</p> <h2 class="flower">Tulip</h2> <p>This is one of the best flowers also..</p> </body> </html>
Source Code Output :
Running