简体   繁体   中英

The input tag's attributes "placeholder" and "aria-label" in html

In the first input tag, what is the purpose of the "placeholder" and "aria-label" attributes? Are they the same as the "name" and "value" in the second input tag

<input type="search" placeholder="Search" aria-label="Search">
<input type="search" name="Search" value="Search">

No, they work differently.

I suppose you are talking about inputs. Placeholders are the gray texts inside the fields, and they are only for display. You can actually access an element by its name and not the placeholder.


Aria-label allows us to specify a string to be used as the accessible label. This overrides any other native labeling mechanism, such as a label element — for example, if a button has both text content and an aria-label, only the aria-label value will be used. While values are, well, values

The aria-label attribute is used to define a string that labels the current element. The placeholder attribute specifies a short hint that describes the expected value of an input field (eg a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.

No, they are not same

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM