--- title: Lista de atributos HTML slug: Web/HTML/Atributos tags: - HTML - Referencia - Web - atributo translation_of: Web/HTML/Attributes ---

Elementos em HTML têm atributos; estes são valores adicionais que configuram os elementos ou ajustam o seu comportamento em vários modos para corresponderem aos critérios que os utilizadores pretendem.

Lista de Atributos

Nome do Atributo Elementos Descrição
accept {{ HTMLElement("form") }}, {{ HTMLElement("input") }} Lista de tipos que o servidor aceita, é usualmente um tipo de ficheiro.
accept-charset {{ HTMLElement("form") }} Lista de codificações de caracteres (charsets) que são suportadas.
accesskey Atributo global Define um atalho do teclado para activar ou adicionar foco ao elemento.
action {{ HTMLElement("form") }} O URI dum programa que processa a informação submetida através deste formulário.
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") }} Especifica o alinhamento horizontal do elemento.
alt {{ HTMLElement("applet") }}, {{ HTMLElement("area") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }} Texto alternativo no caso de uma imagem não poder ser mostrada.
async {{ HTMLElement("script") }} Indicates that the script should be executed asynchronously.
autocomplete {{ HTMLElement("form") }}, {{ HTMLElement("input") }} Indicates whether controls in this form can by default have their values automatically completed by the browser.
autofocus {{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} The element should be automatically focused after the page loaded.
autoplay {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} The audio or video should play as soon as possible.
autosave {{ HTMLElement("input") }} Previous values should persist dropdowns of selectable values across page loads.
bgcolor {{ HTMLElement("body") }}, {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}, {{ HTMLElement("marquee") }}, {{ HTMLElement("table") }}, {{ HTMLElement("tbody") }}, {{ HTMLElement("tfoot") }}, {{ HTMLElement("td") }}, {{ HTMLElement("th") }}, {{ HTMLElement("tr") }}

Background color of the element.

Nota: This is a legacy attribute. Please use the CSS {{ Cssxref("background-color") }} property instead.

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

The border width.

Nota: This is a legacy attribute. Please use the CSS {{ Cssxref("border") }} property instead.

buffered {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} Contains the time range of already buffered media.
challenge {{ HTMLElement("keygen") }} A challenge string that is submitted along with the public key.
charset {{ HTMLElement("meta") }}, {{ HTMLElement("script") }} Declares the character encoding of the page or script.
checked {{ HTMLElement("command") }}, {{ HTMLElement("input") }} Indicates whether the element should be checked on page load.
cite {{ HTMLElement("blockquote") }}, {{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("q") }} Contains a URI which points to the source of the quote or change.
class Global attribute Often used with CSS to style elements with common properties.
code {{ HTMLElement("applet") }} Specifies the URL of the applet's class file to be loaded and executed.
codebase {{ HTMLElement("applet") }} This attribute gives the absolute or relative URL of the directory where applets' .class files referenced by the code attribute are stored.
color {{ HTMLElement("basefont") }}, {{ HTMLElement("font") }}, {{ HTMLElement("hr") }}

This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format.

Nota: This is a legacy attribute. Please use the CSS {{ Cssxref("color") }} property instead.

cols {{ HTMLElement("textarea") }} Defines the number of columns in a textarea.
colspan {{ HTMLElement("td") }}, {{ HTMLElement("th") }} The colspan attribute defines the number of columns a cell should span.
content {{ HTMLElement("meta") }} A value associated with http-equiv or name depending on the context.
contenteditable Global attribute Indicates whether the element's content is editable.
contextmenu Global attribute Defines the ID of a {{ HTMLElement("menu") }} element which will serve as the element's context menu.
controls {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} Indicates whether the browser should show playback controls to the user.
coords {{ HTMLElement("area") }} A set of values specifying the coordinates of the hot-spot region.
crossorigin {{ HTMLElement("audio") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}, {{ HTMLElement("video") }} How the element handles cross-origin requests
data {{ HTMLElement("object") }} Specifies the URL of the resource.
data-* Global attribute Lets you attach custom attributes to an HTML element.
datetime {{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("time") }} Indicates the date and time associated with the element.
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 Global attribute 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") }} Indicates whether the user can interact with the element.
download {{ HTMLElement("a") }}, {{ HTMLElement("area") }} Indicates that the hyperlink is to be used for downloading a resource.
draggable Global attribute Defines whether the element can be dragged.
dropzone Global attribute Indicates that the element accept the dropping of content on it.
enctype {{ HTMLElement("form") }} Defines the content type of the form date when the method is POST.
for {{ HTMLElement("label") }}, {{ HTMLElement("output") }} Describes elements which belongs to this one.
form {{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} Indicates the form that is the owner of the element.
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") }}

Specifies the height of elements listed here. For all other elements, use the CSS {{cssxref("height")}} property.

Nota: In some instances, such as {{ HTMLElement("div") }}, this is a legacy attribute, in which case the CSS {{ Cssxref("height") }} property should be used instead.

hidden Global attribute Prevents rendering of given element, while keeping child elements, e.g. script elements, active.
high {{ HTMLElement("meter") }} Indicates the lower bound of the upper range.
href {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("link") }}  The URL of a linked resource.
hreflang {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }} Specifies the language of the linked resource.
http-equiv {{ HTMLElement("meta") }}  
icon {{ HTMLElement("command") }} Specifies a picture which represents the command.
id Global attribute Often used with CSS to style a specific element. The value of this attribute must be unique.
integrity {{ HTMLElement("link") }}, {{ HTMLElement("script") }} 

Security Feature that allows browsers to verify what they fetch. 

MDN Link

ismap {{ HTMLElement("img") }} Indicates that the image is part of a server-side image map.
itemprop Global attribute  
keytype {{ HTMLElement("keygen") }} Specifies the type of key generated.
kind {{ HTMLElement("track") }} Specifies the kind of text track.
label {{ HTMLElement("track") }} Specifies a user-readable title of the text track.
lang Global attribute 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") }} Provides a hint to the user of what can be entered in the field.
poster {{ HTMLElement("video") }} A URL indicating a poster frame to show until the user plays or seeks.
preload {{ HTMLElement("audio") }}, {{ HTMLElement("video") }} Indicates whether the whole resource, parts of it or nothing should be preloaded.
radiogroup {{ HTMLElement("command") }}  
readonly {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} Indicates whether the element can be edited.
rel {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }} Specifies the relationship of the target object to the link object.
required {{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} Indicates whether this element is required to fill out or not.
reversed {{ HTMLElement("ol") }} Indicates whether the list should be displayed in a descending order instead of a ascending.
rows {{ HTMLElement("textarea") }} Defines the number of rows in a text area.
rowspan {{ HTMLElement("td") }}, {{ HTMLElement("th") }} Defines the number of rows a table cell should span over.
sandbox {{ HTMLElement("iframe") }}  
scope {{ HTMLElement("th") }}  
scoped {{ HTMLElement("style") }}  
seamless {{ HTMLElement("iframe") }}  
selected {{ HTMLElement("option") }} Defines a value which will be selected on page load.
shape {{ HTMLElement("a") }}, {{ HTMLElement("area") }}  
size {{ HTMLElement("input") }}, {{ HTMLElement("select") }} Defines the width of the element (in pixels). If the element's type attribute is text or password then it's the number of characters.
sizes {{ HTMLElement("link") }}, {{ HTMLElement("img") }}, {{ HTMLElement("source") }}  
slot Global attribute Assigns a slot in a shadow DOM shadow tree to an element.
span {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}  
spellcheck Global attribute Indicates whether spell checking is allowed for the element.
src {{ HTMLElement("audio") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("track") }}, {{ HTMLElement("video") }} The URL of the embeddable content.
srcdoc {{ HTMLElement("iframe") }}  
srclang {{ HTMLElement("track") }}  
srcset {{ HTMLElement("img") }}  
start {{ HTMLElement("ol") }} Defines the first number if other than 1.
step {{ HTMLElement("input") }}  
style Global attribute Defines CSS styles which will override styles previously set.
summary {{ HTMLElement("table") }}  
tabindex Global attribute Overrides the browser's default tab order and follows the one specified instead.
target {{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("form") }}  
title Global attribute Text to be displayed in a tooltip when hovering over the element.
type {{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("command") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("object") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("style") }}, {{ HTMLElement("menu") }} Defines the type of the element.
usemap {{ HTMLElement("img") }},  {{ HTMLElement("input") }}, {{ HTMLElement("object") }}  
value {{ HTMLElement("button") }}, {{ HTMLElement("option") }}, {{ HTMLElement("input") }}, {{ HTMLElement("li") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("param") }} Defines a default value which will be displayed in the element on page load.
width {{ HTMLElement("canvas") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}, {{ HTMLElement("video") }}

For the elements listed here, this establishes the element's width.

Nota: For all other instances, such as {{ HTMLElement("div") }}, this is a legacy attribute, in which case the CSS {{ Cssxref("width") }} property should be used instead.

wrap {{ HTMLElement("textarea") }} Indicates whether the text should be wrapped.

Conteúdo versus atributos IDL

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.

Consulte também