主頁
HTML
HTML 類
Tryit:兩個元素 - 一個類
執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 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>