HTML The class Attribute


SUBMITTED BY: whtm

DATE: Dec. 27, 2016, 9:28 a.m.

FORMAT: Text only

SIZE: 910 Bytes

HITS: 1017

  1. Using The class Attribute
  2. The HTML class attribute makes it possible to define equal styles for elements with the same class name.
  3. Here we have three <div> elements that points to the same class name:
  4. Example
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <style>
  9. div.cities {
  10. background-color: black;
  11. color: white;
  12. margin: 20px 0 20px 0;
  13. padding: 20px;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div class="cities">
  19. <h2>London</h2>
  20. <p>London is the capital of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
  21. </div>
  22. <div class="cities">
  23. <h2>Paris</h2>
  24. <p>Paris is the capital and most populous city of France.</p>
  25. </div>
  26. <div class="cities">
  27. <h2>Tokyo</h2>
  28. <p>Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
  29. and the most populous metropolitan area in the world.</p>
  30. </div>
  31. </body>
  32. </html>

comments powered by Disqus