Home
HTML
HTML Classes
Tryit: two elements - one class
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> .city { background-color: tomato; color: white; padding: 10px; } </style> </head> <body> <h2>Different Elements Can Share Same Class</h2> <p>Even if the two elements do not have the same tag name, they can both point to the same class, and get the same CSS styling:</p> <h2 class="city">Paris</h2> <p class="city">Paris is the capital of France.</p> </body> </html>