What is name attribute in html

What is name attribute in HTML5?

The name attribute defines the name of the form control, and is submitted along with the form control’s value when the form is submitted. It is the name part of the name/value pair associated with an element for the purposes of form submission.

How do you edit attributes in HTML?

You can edit attributes in two ways: Using the Attributes tool….To change the value of an attribute:

  1. Click within the element and press the F2 key to select the element of interest.
  2. When the element is selected, click on the name of the attribute you want to modify, to display the editing form of its value.

Can we use name attribute in HTML?

The name attribute specifies a name for an HTML element. This name attribute can be used to reference the element in a JavaScript. For a element, the name attribute specifies a name for the information/value of the content attribute.

How do you name an element in HTML?

Naming your code using the id attribute After you define the attribute in the HTML file, you refer to the HTML element in your CSS by writing a hashtag ( # ) followed by the attribute value.

What is the purpose of the attribute name?

The name attribute specifies the name of an element. The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted. Note: Only form elements with a name attribute will have their values passed when submitting a form.

What is the difference between id and name attribute in HTML?

ID is a global attribute and applies to virtually all elements in HTML. It is used to uniquely identify elements on the Web page, and its value is mostly accessed from the frontend (typically through JavaScript or jQuery). name is an attribute that is useful to specific elements (such as form elements, etc.) in HTML.

How do you edit attributes?

In the list of attributes, double-click the attribute you want to edit, or select the attribute and click Edit. In the Edit Attribute dialog box, make changes on the following tabs and click OK: Attribute tab.

How do you modify attributes?

To Edit Attribute Values and Properties for a Block Reference

  1. Click Home tab Block panel Edit Single Attribute. Find.
  2. In the drawing area, select the block you want to edit.
  3. In the Enhanced Attribute Editor, select the attribute you want to edit.
  4. Make the attribute changes you want, and then do one of the following:
Читайте также:  Css при наведении появляется тень

Why do we need name attribute in HTML?

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted. Note: Only form elements with a name attribute will have their values passed when submitting a form.

Which HTML elements have name attribute?

“name gets or sets the name property of a DOM object; it only applies to the following elements: , , , , , , , , , , , , , and .”

How do you name a website in HTML?

The tag defines the title of the document. The title must be text-only, and it is shown in the browser’s title bar or in the page’s tab. The tag is required in HTML documents! The contents of a page title is very important for search engine optimization (SEO)!

What is attribute in HTML with example?

An HTML attribute is a piece of markup language used to adjust the behavior or display of an HTML element. For example, attributes can be used to change the color, size, or functionality of HTML elements. Attributes are used by including them in an opening HTML tag: Content

Источник

HTML name Attribute

The name attribute specifies a name for an HTML element.

This name attribute can be used to reference the element in a JavaScript.

For a element, the name attribute is used as a reference when the data is submitted.

For an element, the name attribute can be used to target a form submission.

For a element, the name attribute is associated with the ‘s usemap attribute and creates a relationship between the image and the map.

For a element, the name attribute specifies a name for the information/value of the content attribute.

For a element, the name attribute is used together with the value attribute to specify parameters for the plugin specified with the tag.

Applies to

The name attribute can be used on the following elements:

Examples

Example

Two buttons with equal names, that submit different values when clicked:

Fieldset Example

Form Example

An HTML form with a name attribute:

Iframe Example

An that act as a target for a link:

Input Example

An HTML form with three input fields; two text fields and one submit button:

Map Example

An image map, with clickable areas:

Meta Example

Use the name attribute to define a description, keywords, and the author of an HTML document:

Object Example

An element with a name attribute:

Output Example

Perform a calculation and show the result in an element:

Param Example

Set the «autoplay» parameter to «true», so the sound will start playing as soon as the page loads:

Select Example

A drop-down list with a name attribute:

Textarea Example

A text area with a name attribute:

Browser Support

The multiple attribute has the following browser support for each element:

Element
button Yes Yes Yes Yes Yes
fieldset Yes Not supported Yes Yes Yes
form Yes Yes Yes Yes Yes
iframe Yes Yes Yes Yes Yes
input 1.0 2.0 1.0 1.0 1.0
map Yes Yes Yes Yes Yes
meta Yes Yes Yes Yes Yes
object Yes Yes Yes Yes Yes
output 10.0 Not supported 4.0 5.1 11.0
param Yes Yes Yes Yes Yes
select Yes Yes Yes Yes Yes
textarea Yes Yes Yes Yes Yes

Источник

What is name Attribute in HTML?

Javascript Course - Mastering the Fundamentals

The ‘name‘ attribute specifies a them to an element that is used during form submission and as a reference for other purposes.

  • It is used to identify the input value if it is sent to a server via a traditional GET or POST of a form.
  • Unlike id , the name attribute may not be unique across the entire page.
  • The name attribute can be used as a reference by JavaScript, HTML, CSS, and in submitted form data.
Читайте также:  Php script post request

Syntax

Example

  • In the above example, the name attribute in is used to reference the form data after form submission.
  • The name attribute in identifies the dropdown list (with 3 values — S, M, L).

Supported elements

Type of Value

  • The value acts as an identifier. That is, it is a name used to identify the element.
  • The ‘name’ attribute does not have any default value.

Value

It is generally a string value.

Supported doctypes

The ‘name’ attribute for elements like button, textarea, select, form, img, a input, object, map, and param is supportext areaTML 4.01 strict, HTML 4.01 transitional, and HTML 4.01 frameset.

4.01 frameset for the frame, iframe.

More Examples

Examples of name attributes with their supporting elements:

button

The name attribute in is used to reference the form data after form submission or reference the element in JavaScript. It contains a single value name that describes the name of the element.

name-attribute-example-button

Output

textarea

The HTML name Attribute is used to reference the form data after the form submission or reference the element in JavaScript. The value assigned to the name attribute is used to identify a specific textarea element.

name-attribute-example-text-area

Output

select

The name Attribute in specifies a name for the drop-down list. It is used to reference the form data after form submission or to reference the element in JavaScript.

name-attribute-example-select

Output

form

The HTML name Attribute is used to reference the form data after form submission or reference the element in JavaScript. It is a single value name that specifies the name of the element.

name-attribute-example-form

Output

fieldset

The name Attribute in the element is used to refer to all input elements of the fieldset. It is used to reference the form data after submitting the form or to reference the element in JavaScript.

name-attribute-example-fieldset

Output

frame

The name attribute specifies the name of a element. The name attribute is used to reference the element in JavaScript or to act as a target for a link. The frame tag is not supported in HTML5.

iframe

The name attribute in the element is used to identify an Element. The name attribute is also used as a reference to the elements in Javascript.

name-attribute-example-iframe-output

Output

img

The name attribute in the` element is used to identify an image. The name attribute is obsolete in HTML5 (id can be used instead of it

name-attribute-example-img-output

Output

a

The name attribute is used in Anchor Tag to specify the name of an anchor and “jump” to a specific point on a web page. It is mainly used in large pages or subdivisions. The name attribute for the tag is not supported in HTML5 (id can be used instead).

html-name-attribute-example

Output

input

The name attribute is used to specify a name for an element and references the form data after submitting the form or to reference the element in JavaScript.

example-name-attribute-html

Output

object

The name attribute in is used to specify the name of the embedded file. This attribute is also used as a reference for an object element in Javascript.

name-attribute-example-object-output

Output

map

The name attribute in is used to specify the name of the image map and is associated with the usemap attribute. It creates a relationship between the image and the map.

Читайте также:  font-style

param

The value set to the name Attribute of is used to specify a name for the element. The name attribute is used along with the value attribute to define a parameter for plug-ins associated with the element.

meta

The HTML name Attribute is used to specify the name for the metadata. This attribute is used to define the name for the information/value of the content attribute. Either the http-equiv attribute or the name attribute should be set.

What is the Purpose of the HTML name Attribute?

The name attribute identifies a specific element to contribute to the form data sent to a server. Thus, in the case of submitting the value of the control to the server-side processing, the name attribute is a must.

However, it can be neglected if no control value is submitted. For example, the name attribute can be ignored, if there is a single submit button. However, if there are multiple submit buttons the name attribute is used to recognize which button was used on the server side.

The name attribute is allowed and recognized in some elements, disallowed, and ignored in others, and when allowed, its meaning is defined in the definition of the element.

Supported Browsers

The browsers and their first version that supported the name attribute are as follows:

Learn more

To know more about Attributes in HTML head over to Attributes in HTML.

Conclusion

  • The name attribute acts as an identifier for an element.
  • This attribute helps in referencing elements in JavaScript.
  • It plays a major role in submitting the value of the control to the server side.
  • The name attribute is supported by some elements like , , , , , etc.

Источник

HTML Атрибут name

Атрибут name можно использовать для ссылки на элемент в JavaScript.

Для элемента form , атрибут name также используется в качестве ссылки при представлении данных.

Для элемента iframe , атрибут name может использоваться для целевой отправки формы.

Для элемента map , атрибут name связан с атрибут usemap создает связь между изображением и картой.

Для элемента meta , атрибут name задает имя для информации / значения атрибута content .

Для элемента param , атрибут name используется вместе с атрибутом value для задания параметров плагина, указанного в теге .

Применение

Атрибут name можно использовать для следующих элементов:

Примеры

Пример

Две кнопки с одинаковыми именами, которые отправляют разные значения при нажатии:

Пример Fieldset

Пример Form

Форма HTML с атрибутом name:

Пример Iframe

Элемент действует как цель для ссылки:

Пример Input

форма HTML с тремя полями ввода; два текстовых поля и одна кнопка отправки:

Пример Map

Изображение-карта с кликабельными областями:

Пример Meta

Атрибут name используется для определения описания, ключевых слов и автора документа HTML:

Пример Object

Пример Output

Выполните расчет и покажите результат в элементе :

Пример Param

Установите «autoplay» параметр к «true», таким образом, звук начнет играть, как только страница будет загружаться:

Пример Select

Раскрывающийся список с атрибутом name:

Пример Textarea

Текстовое поле с атрибутом name:

Поддержка браузеров

Атрибут multiple имеет следующую поддержку браузера для каждого элемента:

Элемент
button Да Да Да Да Да
fieldset Да Не поддерживает Да Да Да
form Да Да Да Да Да
iframe Да Да Да Да Да
input 1.0 2.0 1.0 1.0 1.0
map Да Да Да Да Да
meta Да Да Да Да Да
object Да Да Да Да Да
output 10.0 Не поддерживает 4.0 5.1 11.0
param Да Да Да Да Да
select Да Да Да Да Да
textarea Да Да Да Да Да

Мы только что запустили
SchoolsW3 видео

Источник

Оцените статью