HTML Id

The id is an abbreviation of identifier – so you use the id-attribute when you want to be able to identify this specific element. Id value can be used by both CSS and Javascript. In CSS to select element by id used (#) tag.

Example

  

<!DOCTYPE html>
<html>
    <head>
        <title>Page Title</title>
<style>
#right-column {
  background-color: lightblue;
  color: black;
  padding: 40px;
  text-align: center;

#left-column {
  background-color: pink;
  color: black;
  padding: 40px;
  text-align: center;

</style>
    </head>
    <body>
 <div id="right-column">Column first</div>
<div id="left-column"> Column second</div>  
    </body>
</html>

Output:

Conclusion

In this tutorial we learn id selectors and previous tutorials we learn about class selectors so i hope you can understand easily both selectors.

Powered  by Codersarts