• Good e-commerce,Welcome!
Home > Cross border EC > Shopee

What do name and ID mean in HTML?

| 1Person Answer

html的name和id可以类比身份证的姓名和身份证编号

编号id具有唯一性,一个id只出现一次。

名称name具备可重复性,可以多次出现。

在css中两者都具备识别html元素的作用,name用点号.表示,id用井号#

一般name用于通用多次出现元素的样式定义,id用于唯一性元素样式定义。

在表单当中,由于有些控件具备多元素特性,例如radio checkbox等,使用id不便于表单数据的提交,此外浏览器会根据name来设定发送到服务器的request,因此在表单当中,用name来提交数据。

当然,在实际的html中,也完全可以不用id,用单独的class也可以起到代替id的作用。但是在js中,是无法通过class直接后去html元素的, 定义id便于相关操作。

Professional answer

C

互动电商

提供电商新闻、干货及实操技巧,。

The name and ID of HTML can be compared to the name and ID number of an ID card.

The ID number is unique and an ID only appears once.

The name is repeatable and can appear multiple times.

In CSS, both have the function of identifying HTML elements. Name is represented by a period. and ID is represented by a pound sign #.

Generally, name is used for the style definition of common elements that appear multiple times, and ID is used for the style definition of unique elements.

In forms, since some controls have multi-element features, such as radio checkbox, etc., using ID is not convenient for submitting form data. In addition, the browser will set the request sent to the server based on the name. Therefore, in the form, name is used to submit data.

Of course, in actual HTML, ID can be completely omitted. A separate class can also replace ID. However, in JS, it is impossible to directly access HTML elements through class. Defining ID facilitates related operations.

Similar Q&A

recommend I want to start my own business, how can I find a project?

    E-c News Continuously pushing e-commerce knowledge to you

    African netizens use China Africa cross-border e-commerce platform for online shopping
    looking at China's modern business history, the word "profiteer" must be familiar to everyone. To put it bluntly, profiteer is a person who earns a pric...
    how is the new seller of cross-border e-commerce doing?
    I believe many treasure mothers have an idea to do their own business and want to increase their income. Go to work, but you can't take care of your chi...
    how can cross-border e-commerce Amazon sell on Amazon platform without goods?
    cross border e-commerce trade entities in different customs territories conduct trade on the Internet, and then complete the whole transaction through cross-...
    Amazon store opening process and cost analysis!
    With the rapid development of cross-border e-commerce, more and more sellers want to enter Amazon. However, many people are still new to Amazon's cross-...
    Amazon plans to expand its pharmacy business on a large scale and will add same day delivery service
    Amazon Pharmacy says its growth strategy relies on the development and launch of “modular” pharmacies of varying sizes. (Amazon)
    It's convenient! Taobao adds WeChat Pay function
    On September 4th, Taobao and Tmall announced that in order to enhance consumers' shopping experience, Taobao plans to add WeChat payment capabilities an...
    China's Taobao working with startup on deliveries by reusable rocket
    SHENZHEN, China (hb2b) - Chinese rocket maker Space Epoch is working with Alibaba's online shopping platform Taobao to make reusable rockets for express...

    Latest Q&A More

    Popular tags