In the HTML, the difference between ID, Name, class three

Source: Internet
Author: User

Bo Master into the front-end course of study also on 1 weeks, including himself, many students around the ID, name, classs the properties of the three tags are not very clear, so after consulting the relevant information, made their own knowledge within the scope of the following summary:

  

For example, ID is like identity card identification number, each person's identity card number is not the same, is unique; name is like the name on the ID card, it is just a code name, it is not unique; the gender, Han, and class attributes on the identity card are similar and are collectively referred to as a category.

A simple picture of an ID card should be able to accurately distinguish the differences between the three, let's look at their respective uses:

First, ID

First we know that the ID is unique in a Web page, and it is used more when contacting the background. To the Bo master at this stage of learning, ID has not yet entered the field I have learned to master.

Second, name

The name attribute appears more in the tagged elements that have been learned than the ID, most often in <input> and anchor points.

Applications in the 1.<input>

<type= "Radio"  name= "Sex"/> male <     type = "Radio" name = "Sex"/> Female 

For the above code, when choosing the gender, we need to appear a single radio, so for two input tags, need to name the same name.

2. Anchor Point

< H3 ><  name= "Maodian"></a> title </h3  ><href= "#maodian"> jump to Title  </a>

Third, class

Class is the kind of setting tag that is used to set the CSS style, as compared to ID and name. Just as we need to extract the Han population in a city of tens of millions of people, your name will not affect this.

The above is the Bo master on the ID, name, class, a summary of the three differences, because only contact it, it is not possible to do in-depth analysis and comparison, of course, I hope this blog can give beginners a help, but also welcome us to discuss with each other, common progress!

In the HTML, the difference between ID, Name, class three

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.