what is html id attribute?

Report
Question
724 views

The id attribute is used to specify the unique ID for an element of the HTML document. It allocates the unique identifier which is used by the CSS and the JavaScript for performing certain tasks.

Please explain why do you think this question should be reported?

Report Cancel
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <title>  
  5. Example of Id attribute in CSS  
  6. </title>  
  7. <style>  
  8. #red {  
  9. padding: 40px;  
  10. background-color: lightblue;  
  11. color: black;      
  12. text-align: center;  
  13. }   
  14.   
  15. #blue 
  16. {  
  17. padding: 50px;  
  18. background-color: lightGreen;  
  19. text-align: center;  
  20. }  
  21. </style>  
  22. </head>  
  23. <body>  
  24. <p> Use CSS to style an element with the id: </p>  
  25. <h1 id="red"> red colour </h1>  
  26. <h1 id="blue"> blue colour</h1>  
  27. </body>  
  28. </html>   

Thread Reply

Leave an comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>