--- title: HTML attribute reference slug: Web/HTML/Attributes translation_of: Web/HTML/Attributes ---

Елементи в HTML можуть мати атрибути; це додаткові величини, які певним чином змінюють безпосередньо елементи або їх поведінку для отримання необхідного користувачеві ефекту.

Список атрибутів

Назва атрибуту Елементи Опис
accept {{ HTMLElement("form") }}, {{ HTMLElement("input") }} Список типів даних, що приймає сервер, зазвичай, типів файлів.
accept-charset {{ HTMLElement("form") }} Список кодувань, які підтримуються.
accesskey Глобальний атрибут Визначає комбінацію клавіш швидкого доступу для активації або фокусування на елементі.
action {{ HTMLElement("form") }} URI програми, яка обробляє інформацію, передану формою.
align {{ HTMLElement("applet") }}, {{ HTMLElement("caption") }}, {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }},  {{ HTMLElement("hr") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("table") }}, {{ HTMLElement("tbody") }},  {{ HTMLElement("td") }},  {{ HTMLElement("tfoot") }} , {{ HTMLElement("th") }}, {{ HTMLElement("thead") }}, {{ HTMLElement("tr") }} Визначає вирівнювання елементу по горизогталі
alt {{ HTMLElement("applet") }}, {{ HTMLElement("area") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }} Показує альтарнативний текст у разі неможливості відобразити зображення.
async {{ HTMLElement("script") }} Вказуєна те, що скрипт повинен виконуватися асинхронно.
autocomplete {{ HTMLElement("form") }}, {{ HTMLElement("input") }} Вказує чи дозволено автозаповнення полів браузером.
autofocus {{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} Після завантаження сторінки, відбуватиметься автоматичне фокусування на цьому елементі.
autoplay {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} Відтворює аудіо чи відео одразу, коли це стає можливим.
autosave {{ HTMLElement("input") }} Попередні значення повинні зберігатися у випадному списку, щоб можна було обрати значення з різних завантажень сторніки.
bgcolor {{ HTMLElement("body") }}, {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}, {{ HTMLElement("marquee") }}, {{ HTMLElement("table") }}, {{ HTMLElement("tbody") }}, {{ HTMLElement("tfoot") }}, {{ HTMLElement("td") }}, {{ HTMLElement("th") }}, {{ HTMLElement("tr") }}

Визначає колір заднього фону елементу.

Примітка: Це застарілий атрибут. Натомість краще використовувати CSS-властивість {{ Cssxref("background-color") }}.

border {{ HTMLElement("img") }}, {{ HTMLElement("object") }}, {{ HTMLElement("table") }}

Ширина границі.

Примітка: Це застарілий атрибут. Натомість краще використовувати CSS-властивість {{ Cssxref("border") }}.

buffered {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} Містить тривалість часу буферованого медіафайлу.
challenge {{ HTMLElement("keygen") }} A challenge string that is submitted along with the public key.
charset {{ HTMLElement("meta") }}, {{ HTMLElement("script") }} Оголошує кодування символів сторінки або скрипту.
checked {{ HTMLElement("command") }}, {{ HTMLElement("input") }} Вказує чи слід перевіряти елемент при завантаженні сторінки.
cite {{ HTMLElement("blockquote") }}, {{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("q") }} Містить URI, що вказує на джерело цитати або зміни.
class Глобальний атрибут Часто використовують з CSS для задання стилю елементів зі спільними властивостями.
code {{ HTMLElement("applet") }} Вказує URL файла класу аплету для завантаження та виконання.
codebase {{ HTMLElement("applet") }} Цей атрибут надає абсолютну чи відносну URL директорії, де зберігаються файли .class аплету.
color {{ HTMLElement("basefont") }}, {{ HTMLElement("font") }}, {{ HTMLElement("hr") }}

Цей атрибут задає колір тексту за назвою кольору або його кодом у шістнадцятковому форматі RRGGBB.

Примітка: Це застарілий атрибут. Натомість краще використовувати CSS-власивість {{ Cssxref("color") }}

cols {{ HTMLElement("textarea") }} Задає кількість колонок в текстовому полі.
colspan {{ HTMLElement("td") }}, {{ HTMLElement("th") }} Цей атрибут задає кількість стовпців, яку займає одна комірка таблиці вширину.
content {{ HTMLElement("meta") }} Знаення, пов'язане з http-equiv або name залежно від контексту.
contenteditable Глобальний атрибут Вказує чи можна змінювати вміст елементу.
contextmenu Глобальний атрибут Визначає ID елементу {{ HTMLElement("menu") }}, який слугуватиме контекстним меню елемента.
controls {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} Вказує чи браузер відображатиме панель управління медіа користувачеві.
coords {{ HTMLElement("area") }} Набір значень, що задають координати активної області.
crossorigin {{ HTMLElement("audio") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}, {{ HTMLElement("video") }} Визначає як елемент поводиться з запитами до різних джерел.
data {{ HTMLElement("object") }} Задає URL джерела.
data-* Глобальний атрибут Дозволяє вам застосовувати до HTML-елемента користувацькі атрибути.
datetime {{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("time") }} Вказує час та дату, пов'язані з елементтом.
default {{ HTMLElement("track") }} Indicates that the track should be enabled unless the user's preferences indicate something different.
defer {{ HTMLElement("script") }} Indicates that the script should be executed after the page has been parsed.
dir Глобальний атрибут Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
dirname {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}  
disabled {{ HTMLElement("button") }}, {{ HTMLElement("command") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} Вказує на можливість взаємодії користувача з елементом.
download {{ HTMLElement("a") }}, {{ HTMLElement("area") }} Вказує на те, що посилання використовується для завантаження.
draggable Глобальний атрибут Визначає чи можна перетягувати елемент.
dropzone Глобальний атрибут Вказує чи може елемент приймати перетягування на нього контенту.
enctype {{ HTMLElement("form") }} Defines the content type of the form date when the method is POST.
for {{ HTMLElement("label") }}, {{ HTMLElement("output") }} Описує елементи, які належать до цього елементу.
form {{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} Визначає форму, яка є батьківською для цього елементу.
formaction {{ HTMLElement("input") }}, {{ HTMLElement("button") }} Indicates the action of the element, overriding the action defined in the {{ HTMLElement("form") }}.
headers {{ HTMLElement("td") }}, {{ HTMLElement("th") }} IDs of the <th> elements which applies to this element.
height {{ HTMLElement("canvas") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}, {{ HTMLElement("video") }}

Задає висоту перелічених елементів. Для інших елементів краще використовувати CSS-властивість {{cssxref("height")}}.

Примітка: У деяких випадках, зокрема для {{ HTMLElement("div") }}, це застарілий атрибут. Натомість для нього краще застосовувати CSS-властивість {{ Cssxref("height") }}.

hidden Глобальний атрибут Не дозволяє рендеринг певного елемента, але не скасовує рендеринг дочірніх елементів, наприклад, скриптових і активних.
high {{ HTMLElement("meter") }} Вказує нижню межу верхнього діапазону.
href {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("link") }}  URL посилання на певне джерело.
hreflang {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }} Вказує на мову сторінки, на яку буде перейдено за посиланням.
http-equiv {{ HTMLElement("meta") }}  
icon {{ HTMLElement("command") }} Задає картинку, яка відображає команду.
id Глобальний атрибут Часто використовується з CSS для задання стилю конкретному елементу. Значення цього атрибути повинно бути унікальним.
integrity {{ HTMLElement("link") }}, {{ HTMLElement("script") }} 

Додатковий рівень захисту, дає змогу браузеру ідентифікувати, чи він стягує потрібний файл.

Посилання MDN

ismap {{ HTMLElement("img") }} Вказує на те, що зображення є частиною заображення серверної карти.
itemprop Глобальний атрибут  
keytype {{ HTMLElement("keygen") }} Визначає тип генерованого ключа.
kind {{ HTMLElement("track") }} Specifies the kind of text track.
label {{ HTMLElement("track") }} Specifies a user-readable title of the text track.
lang Глобальний атрибут Defines the language used in the element.
language {{ HTMLElement("script") }} Defines the script language used in the element.
list {{ HTMLElement("input") }} Identifies a list of pre-defined options to suggest to the user.
loop {{ HTMLElement("audio") }}, {{ HTMLElement("bgsound") }}, {{ HTMLElement("marquee") }}, {{ HTMLElement("video") }} Indicates whether the media should start playing from the start when it's finished.
low {{ HTMLElement("meter") }} Indicates the upper bound of the lower range.
manifest {{ HTMLElement("html") }} Specifies the URL of the document's cache manifest.
max {{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }} Indicates the maximum value allowed.
maxlength {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} Defines the maximum number of characters allowed in the element.
media {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }}, {{ HTMLElement("source") }}, {{ HTMLElement("style") }} Specifies a hint of the media for which the linked resource was designed.
method {{ HTMLElement("form") }} Defines which HTTP method to use when submitting the form. Can be GET (default) or POST.
min {{ HTMLElement("input") }}, {{ HTMLElement("meter") }} Indicates the minimum value allowed.
multiple {{ HTMLElement("input") }}, {{ HTMLElement("select") }} Indicates whether multiple values can be entered in an input of the type email or file.
muted {{ HTMLElement("video") }} Indicates whether the audio will be initially silenced on page load.
name {{ HTMLElement("button") }}, {{ HTMLElement("form") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}, {{ HTMLElement("map") }}, {{ HTMLElement("meta") }}, {{ HTMLElement("param") }} Name of the element. For example used by the server to identify the fields in form submits.
novalidate {{ HTMLElement("form") }} This attribute indicates that the form shouldn't be validated when submitted.
open {{ HTMLElement("details") }} Indicates whether the details will be shown on page load.
optimum {{ HTMLElement("meter") }} Indicates the optimal numeric value.
pattern {{ HTMLElement("input") }} Defines a regular expression which the element's value will be validated against.
ping {{ HTMLElement("a") }}, {{ HTMLElement("area") }}  
placeholder {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} Дає підказку користувачу про те, які дані треба вводити в поле.
poster {{ HTMLElement("video") }} URL, що відображає рамку постера під час програвання або пошуку.
preload {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} Вказує, чи потребує попереднього завантаження контент або його частина.
radiogroup {{ HTMLElement("command") }}  
readonly {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} Вказує чи можна редагувати цей елемент.
rel {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }} Визнчає взаємозв'язок даного об'єкту та об'єкту посилання.
required {{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} Вказує чи заповнення цього елементу є обов'язковим.
reversed {{ HTMLElement("ol") }} Вказує як відображати елементи списку: у порядку зростання чи спадання.
rows {{ HTMLElement("textarea") }} Визначає кількість рядків у текстовому полі.
rowspan {{ HTMLElement("td") }}, {{ HTMLElement("th") }} Визначає кількість рядків, які займає одна комірка таблиці.
sandbox {{ HTMLElement("iframe") }}  
scope {{ HTMLElement("th") }}  
scoped {{ HTMLElement("style") }}  
seamless {{ HTMLElement("iframe") }}  
selected {{ HTMLElement("option") }} Задає значення, яке буде обрано при звантаженні сторінки.
shape {{ HTMLElement("a") }}, {{ HTMLElement("area") }}  
size {{ HTMLElement("input") }}, {{ HTMLElement("select") }} Задає ширину елементу (у пікселях). Якщо елемент є стрічкою або текстом чи паролем, то цей атрибут задає кількість символів в ширину.
sizes {{ HTMLElement("link") }}, {{ HTMLElement("img") }}, {{ HTMLElement("source") }}  
slot Глобальний атрибут Відводить елементу місце у тіньовій моделі документу.
span {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}  
spellcheck Глобальний атрибут Вказує чи дозволена для цього елемента перевірка правопису.
src {{ HTMLElement("audio") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("track") }}, {{ HTMLElement("video") }} URL вбудованого контенту.
srcdoc {{ HTMLElement("iframe") }}  
srclang {{ HTMLElement("track") }}  
srcset {{ HTMLElement("img") }}  
start {{ HTMLElement("ol") }} Задає значення початку відліку, якщо воно повинно бутит відмінним від "1".
step {{ HTMLElement("input") }}  
style Глобальний атрибут Визначає CSS-стилі, які переписуюють попередньо задані властивості.
summary {{ HTMLElement("table") }}  
tabindex Глобальний атрибут Переписує порядок шарів сторінки за замовчуванням та встановлює свій.
target {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("form") }}  
title Глобальний атрибут Текст, який показується при наведенні курсору на елемент.
type {{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("command") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("object") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("style") }}, {{ HTMLElement("menu") }} Визначає тип даних елементу.
usemap {{ HTMLElement("img") }},  {{ HTMLElement("input") }}, {{ HTMLElement("object") }}  
value {{ HTMLElement("button") }}, {{ HTMLElement("option") }}, {{ HTMLElement("input") }}, {{ HTMLElement("li") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("param") }} Задає величину, що буде відображатись за замовчуванням після завантаження сторінки.
width {{ HTMLElement("canvas") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}, {{ HTMLElement("video") }}

Задає ширину для всіх зазначених у списку елементів.

Примітка: У інших випадках, наприклад для елементу  {{ HTMLElement("div") }}, цей атрибут застарілий, і краще використовувати CSS-властивість {{ Cssxref("width") }}.

wrap {{ HTMLElement("textarea") }} Вказує, чи потрібно додавати нові рядки до тексту.

Content versus IDL attributes

In HTML, most attributes have two faces: the content attribute and the IDL attribute.

The content attribute is the attribute as you set it from the content (the HTML code) and you can set it or get it via {{domxref("element.setAttribute()")}} or {{domxref("element.getAttribute()")}}. The content attribute is always a string even when the expected value should be an integer. For example, to set an {{HTMLElement("input")}} element's maxlength to 42 using the content attribute, you have to call setAttribute("maxlength", "42") on that element.

The IDL attribute is also known as a JavaScript property. These are the attributes you can read or set using JavaScript properties like element.foo. The IDL attribute is always going to use (but might transform) the underlying content attribute to return a value when you get it and is going to save something in the content attribute when you set it. In other words, the IDL attributes, in essence, reflect the content attributes.

Most of the time, IDL attributes will return their values as they are really used. For example, the default type for {{HTMLElement("input")}} elements is "text", so if you set input.type="foobar", the <input> element will be of type text (in the appearance and the behavior) but the "type" content attribute's value will be "foobar". However, the type IDL attribute will return the string "text".

IDL attributes are not always strings; for example, input.maxlength is a number (a signed long). When using IDL attributes, you read or set values of the desired type, so input.maxlength is always going to return a number and when you set input.maxlength ,it wants a number. If you pass another type, it is automatically converted to a number as specified by the standard JavaScript rules for type conversion.

IDL attributes can reflect other types such as unsigned long, URLs, booleans, etc. Unfortunately, there are no clear rules and the way IDL attributes behave in conjunction with their corresponding content attributes depends on the attribute. Most of the time, it will follow the rules laid out in the specification, but sometimes it doesn't. HTML specifications try to make this as developer-friendly as possible, but for various reasons (mostly historical), some attributes  behave oddly (select.size, for example) and you should read the specifications to understand how exactly they behave.

Також читай