- HTML Тег атрибут value
- Поддержка браузеров
- Синтаксис
- Значение атрибута
- ВЫБОР ЦВЕТА
- Сообщить об ошибке
- Ваше предложение:
- Спасибо Вам за то, что помогаете!
- HTML Input Attributes
- The value Attribute
- Example
- The readonly Attribute
- Example
- The disabled Attribute
- Example
- The size Attribute
- Example
- The maxlength Attribute
- Example
- The min and max Attributes
- Example
- The multiple Attribute
- Example
- The pattern Attribute
- Example
- The placeholder Attribute
- Example
- The required Attribute
- Example
- The step Attribute
- Example
- The autofocus Attribute
- Example
- The height and width Attributes
- Example
- The list Attribute
- Example
- The autocomplete Attribute
- Example
- HTML Exercises
- HTML Form and Input Elements
- HTML value Attribute
- Applies to
- Examples
- Example
- Example
- Example
- Example
- Example
- Example
- Browser Support
- Атрибут value
- Синтаксис
- Применяется
- Значения
- Значение по умолчанию
- Типы тегов
HTML Тег атрибут value
Атрибут value используется по-разному для разных типов входных данных:
- Для «button», «reset», и «submit» — он определяет текст на кнопке
- Для «text», «password», и «hidden» — он определяет начальное (по умолчанию) значение поля ввода
- Для «checkbox», «radio», и «image» — он определяет значение, связанное с входными данными (это также значение, которое отправляется при отправке)
Примечание: Атрибут value не может быть использован с .
Поддержка браузеров
Цифры в таблице указывают первую версию браузера, которая полностью поддерживает этот атрибут.
Атрибут | |||||
---|---|---|---|---|---|
value | Да | Да | Да | Да | Да |
Синтаксис
Значение атрибута
Мы только что запустили
SchoolsW3 видео
ВЫБОР ЦВЕТА
Сообщить об ошибке
Если вы хотите сообщить об ошибке или внести предложение, не стесняйтесь отправлять на электронное письмо:
Ваше предложение:
Спасибо Вам за то, что помогаете!
Ваше сообщение было отправлено в SchoolsW3.
ТОП Учебники
ТОП Справочники
ТОП Примеры
Получить сертификат
SchoolsW3 оптимизирован для бесплатного обучения, проверки и подготовки знаний. Примеры в редакторе упрощают и улучшают чтение и базовое понимание. Учебники, ссылки, примеры постоянно пересматриваются, чтобы избежать ошибок, но не возможно гарантировать полную правильность всего содержания. Некоторые страницы сайта могут быть не переведены на РУССКИЙ язык, можно отправить страницу как ошибку, так же можете самостоятельно заняться переводом. Используя данный сайт, вы соглашаетесь прочитать и принять Условия к использованию, Cookies и политика конфиденциальности.
HTML Input Attributes
This chapter describes the different attributes for the HTML element.
The value Attribute
The input value attribute specifies an initial value for an input field:
Example
Input fields with initial (default) values:
The readonly Attribute
The input readonly attribute specifies that an input field is read-only.
A read-only input field cannot be modified (however, a user can tab to it, highlight it, and copy the text from it).
The value of a read-only input field will be sent when submitting the form!
Example
The disabled Attribute
The input disabled attribute specifies that an input field should be disabled.
A disabled input field is unusable and un-clickable.
The value of a disabled input field will not be sent when submitting the form!
Example
The size Attribute
The input size attribute specifies the visible width, in characters, of an input field.
The default value for size is 20.
Note: The size attribute works with the following input types: text, search, tel, url, email, and password.
Example
Set a width for an input field:
The maxlength Attribute
The input maxlength attribute specifies the maximum number of characters allowed in an input field.
Note: When a maxlength is set, the input field will not accept more than the specified number of characters. However, this attribute does not provide any feedback. So, if you want to alert the user, you must write JavaScript code.
Example
Set a maximum length for an input field:
The min and max Attributes
The input min and max attributes specify the minimum and maximum values for an input field.
The min and max attributes work with the following input types: number, range, date, datetime-local, month, time and week.
Tip: Use the max and min attributes together to create a range of legal values.
Example
Set a max date, a min date, and a range of legal values:
The multiple Attribute
The input multiple attribute specifies that the user is allowed to enter more than one value in an input field.
The multiple attribute works with the following input types: email, and file.
Example
A file upload field that accepts multiple values:
The pattern Attribute
The input pattern attribute specifies a regular expression that the input field’s value is checked against, when the form is submitted.
The pattern attribute works with the following input types: text, date, search, url, tel, email, and password.
Tip: Use the global title attribute to describe the pattern to help the user.
Tip: Learn more about regular expressions in our JavaScript tutorial.
Example
An input field that can contain only three letters (no numbers or special characters):
The placeholder Attribute
The input placeholder attribute specifies a short hint that describes the expected value of an input field (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.
The placeholder attribute works with the following input types: text, search, url, tel, email, and password.
Example
An input field with a placeholder text:
The required Attribute
The input required attribute specifies that an input field must be filled out before submitting the form.
The required attribute works with the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.
Example
The step Attribute
The input step attribute specifies the legal number intervals for an input field.
Example: if step=»3″, legal numbers could be -3, 0, 3, 6, etc.
Tip: This attribute can be used together with the max and min attributes to create a range of legal values.
The step attribute works with the following input types: number, range, date, datetime-local, month, time and week.
Example
An input field with a specified legal number intervals:
Note: Input restrictions are not foolproof, and JavaScript provides many ways to add illegal input. To safely restrict input, it must also be checked by the receiver (the server)!
The autofocus Attribute
The input autofocus attribute specifies that an input field should automatically get focus when the page loads.
Example
Let the «First name» input field automatically get focus when the page loads:
The height and width Attributes
The input height and width attributes specify the height and width of an element.
Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. Without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).
Example
Define an image as the submit button, with height and width attributes:
The list Attribute
The input list attribute refers to a element that contains pre-defined options for an element.
Example
An element with pre-defined values in a :
The autocomplete Attribute
The input autocomplete attribute specifies whether a form or an input field should have autocomplete on or off.
Autocomplete allows the browser to predict the value. When a user starts to type in a field, the browser should display options to fill in the field, based on earlier typed values.
The autocomplete attribute works with and the following types: text, search, url, tel, email, password, datepickers, range, and color.
Example
An HTML form with autocomplete on, and off for one input field:
Tip: In some browsers you may need to activate an autocomplete function for this to work (Look under «Preferences» in the browser’s menu).
HTML Exercises
HTML Form and Input Elements
For a complete list of all available HTML tags, visit our HTML Tag Reference.
HTML value Attribute
For , and elements, the value attribute specifies the initial value of the element.
For elements, the value attribute specifies the current value of the gauge.
For elements, the value attribute specifies how much of the task has been completed.
For elements, the value attribute specifies the value of the parameter.
Applies to
The value attribute can be used on the following elements:
Examples
Example
Two buttons with equal names, that submit different values when clicked:
Example
An HTML form with initial (default) values:
Use of the value attribute in an ordered list:
Example
A gauge with a current value, min, max, high, and low segments:
Example
A drop-down list inside an HTML form:
Example
Example
Set the «autoplay» parameter to «true», so the sound will start playing as soon as the page loads:
Browser Support
The value attribute has the following browser support for each element:
Element | |||||
---|---|---|---|---|---|
button | Yes | Yes | Yes | Yes | Yes |
input | 1.0 | 2.0 | 1.0 | 1.0 | 1.0 |
li | Yes | Yes | Yes | Yes | Yes |
meter | 8.0 | 13.0 | 6.0 | 6.0 | 11.0 |
option | Yes | Yes | Yes | Yes | Yes |
progress | 8.0 | 10.0 | 16.0 | 6.0 | 11.0 |
param | Yes | Yes | Yes | Yes | Yes |
Атрибут value
Определяет значение элемента формы, которое будет отправлено на сервер или получено с помощью клиентских скриптов. На сервер отправляется пара «имя=значение», где имя задается атрибутом name тега , а значение — атрибутом value .
В зависимости от типа элемента атрибут value выступает в следующей роли:
- для кнопок ( input type=»button | reset | submit» ) устанавливает текстовую надпись на них;
- для текстовых полей ( input type=»password | text» ) указывает предварительно введенную строку. Пользователь может стирать текст и вводить свои символы, но при использовании в форме кнопки Reset пользовательский текст очищается и восстанавливается введенный в атрибуте value ;
- для флажков и переключателей ( input type=»checkbox | radio» ) уникально определяет каждый элемент, с тем, чтобы клиентская или серверная программа могла однозначно установить, какой пункт выбрал пользователь.
- для файлового поля ( input type=»file» ) не оказывает влияние.
Синтаксис
Применяется
Значения
Значение по умолчанию
Как по вашему мнению расшифровывается аббревиатура "ОС"?
Офицерский состав Операционная система Большой полосатый мух
Не выкладывайте свой код напрямую в комментариях, он отображается некорректно. Воспользуйтесь сервисом cssdeck.com или jsfiddle.net, сохраните код и в комментариях дайте на него ссылку. Так и результат сразу увидят.
Типы тегов
HTML5
Блочные элементы
Строчные элементы
Универсальные элементы
Нестандартные теги
Осуждаемые теги
Видео
Документ
Звук
Изображения
Объекты
Скрипты
Списки
Ссылки
Таблицы
Текст
Форматирование
Формы
Фреймы