what is html id attribute?
ReportQuestion
3 years ago 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.
- <!DOCTYPE html>
- <html>
- <head>
- <title>
- Example of Id attribute in CSS
- </title>
- <style>
- #red {
- padding: 40px;
- background-color: lightblue;
- color: black;
- text-align: center;
- }
- #blue
- {
- padding: 50px;
- background-color: lightGreen;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <p> Use CSS to style an element with the id: </p>
- <h1 id="red"> red colour </h1>
- <h1 id="blue"> blue colour</h1>
- </body>
- </html>
Thread Reply