Category: HTML Attributes

A complete list (and brief description) of every attribute in the HTML specification, including the latest additions in HTML5. Click through to view details, code samples and more for each attribute.

Be sure to check out our HTML tags section, too.

Specifies the interval between valid values in a number-based input.
Specifies that the input field is required; disallows form submission and alerts the user if the required field is empty.
Disallows the user from editing the value of the input.
Specifies placeholder text in a text-based input.
Specifies a regular expression against which to validate the value of the input.
Allows the user to enter multiple values into a file upload or email input.
Specifies a minimum value for number and date input fields.
Specifies a maximum value for number and date input fields.
Specifies the id of a <datalist> element which provides a list of autocomplete suggestions for the input field.
Specifies the height of an image input.
Specifies the browsing context in which to open the response from the server after form submission. For use only on input types of "submit" or "image".
Specifies the HTTP method (GET or POST) to be used when the form data is submitted to the server. Only for use on input types of "submit" or "image".
Specifies the URL for form submission. Can only be used for type="submit" and type="image".
Specifies that the input field should be in focus immediately upon page load.
Places a set of security and usability restrictions on the iframe.
Specifies the initial volume setting of the audio element, in a range from 0.0 to 1.0.
Requests a particular preload behavior to the browser, which the browser may or may not follow.
Specifies that the volume on the audio player should initially be muted.
Specifies that the audio content should loop indefinitely once playback has begun.
Toggles the display of audio playback controls.
Specifies that the audio playback should begin immediately on page load.
Specifies the source file for an audio element.
Provides the meaning or explanation of an abbreviation or acronym.
Specifies the language of the linked resource.
Directs the browser to download the linked resource rather than opening it.
Indicates that CORS headers should be used in the HTTP request, and specifies whether or not to use credentials.
Identifies the intrinsic height of an image file, in CSS pixels.
Defines multiple sizes of the same image, allowing the browser to select the appropriate image source.
NOWRAP indicates that text should not wrap in the cell.
Sets the background color of a single cell in a table.
Sets the color of the entire border around a cell.
Specifies the URL of an image file to be used as the <td> element background image.
Adds a name attribute to a <textarea> element and associates the name with the text added to the text area.
Specifies the visible width of a <textarea> element in average character widths. Defaults to 20 if not specified.
Determines whether or not submitted text wraps when a <textarea> is included in a form submission.
Disables the entry of text into a <textarea> element.
Sets the position of a <textarea> element in the tab order.
Adds an event listener to a <textarea> which executes JavaScript scripting when an onchange event occurs.
Adds an event listener to a <textarea> element which executes JavaScript scripting when an onKeyPress event occurs.
Sets the horizontal alignment for the contents of each <td> element in a table row.
Sets the vertical alignment of all content in a table row.
Sets the background color for a single table row in an HTML table.
Identifies the URL of a file to be used as a background image for a table row.
Sets the border color for all inside borders of a table row.
Was used to set list types.
Defines alternate text, which may be presented in place of the image.
Identified the image or provided additional information about it. Deprecated in HTML 4.0 in favor of other attributes.
Defines a URL at which can be found more information about the image. It was written out of the HTML5 specification, but its status is not quite so clear as other deprecated features.
Indicates the intrinsic width of the image, in CSS pixels.
Was previously used to specify the alignment and placement of an image relative to the surrounding text. It has been deprecated and should not be used.
Previously used to define a border on an image element. It has been deprecated and should no longer be used.
Previously used to add horizontal space on both side of an image. It is now deprecated.
Identifies an image as a server-side image map. When the containing anchor link is clicked, the coordinates of the mouse will be included in the request.
Specifies a client-side image map to be used with the image.
Specified a smaller or lower-quality version of an image.
This attribute does nothing. It was once used by a proprietary software system.
Was intended to prevent users from downloading an image. Was never a part of the HTML specification, and not widely implemented.
An early failed attempt to include native video playback in HTML.
Toggled media player controls when used in conjunction with the dynsrc attribute. Both attributes are now deprecated.
Previously used to specify the number of times a video should play, when used in conjunction with the dynsource attribute. Both attributes have been deprecated.
Was used in conjunction with the dynsrc attribute to add a video that would load in supported browsers in the place of the image that would otherwise be displayed.
Used by the now-defunct Netscape browser to suppress the display of image prior to image download completion.
Specifies the name of an input element. The name and value of each input element are included in the HTTP request when the form is submitted.
Defines an initial value or default selection for an input field.
Specifies the width of the input in characters.
Specifies the maximum number of characters that can be entered in a text-type input.
Specifies whether a checkbox or radio button form input should be checked by default.
Was used to specify a border on an input. Deprecated. Use CSS instead.
Defines the source URL for an image input.
Disables the input field.
Defines a keyboard shortcut for the element.
Was used to indicate the scripting language used for events triggered by the input.
Specifies whether the browser should attempt to automatically complete the input based on user inputs to similar fields.
Specifies a label or prompt text for the document search form.
Specifies a URL to search, instead of the current document.
Specifies the ID of the associated form field element.
Was used to specify the placement of the legend element. Deprecated. Use CSS instead.
Specifies the bullet or numbering style for an individual list item.
Specifies the counter value for a list item within a numbered list.
Specifies the relationship between two linked documents.
Assigns a name to different linked resources so that users can choose between them.
Tells the browser what type of device a resource is designed for.
Describes the linked resource's media type (MIME type).
Assigns a name to an image map.
Provides a context for the value in the contents attribute of a <meta> element.
Defines document header information.
Defines the values for the meta element.
OIOpublisher The <multicol> element is deprecated, and should not be used. Claire Broadley Claire is seasoned technical writer, editor, and… Read More...
The <multicol> element is deprecated, and should not be used. Claire Broadley Claire is seasoned technical writer, editor, and HTML… Read More...
The <multicol> element is deprecated, and should not be used. Claire Broadley Claire is seasoned technical writer, editor, and HTML… Read More...
Specifies the type of list marker that should be used on each item of an unordered list.
Defines the starting number in an ordered list.
Defines the data sent to the server when a form option item is selected.
Defines the default selection in a drop-down list.
Was used to force a paragraph to appear below sibling elements rather than next to sibling elements within a parent element.
Specifies the parameter name.
Specifies the parameter value.
Specifies the media type of the script.
Specifies the URL of an external script.
The defer element of <script> allows a script to load, but pauses the execution of the script until the page… Read More...
The language attribute of <script> was intended as a way to define the scripting language in use. This was never… Read More...
The for attribute of <script> was only supported by Internet Explorer, and is therefore non-standard. We do not recommend its… Read More...
Naming Selection Items The name attribute of <select> means you can easily use your selection field with JavaScript. For more… Read More...
Lets the user select more than one option in the list
Specifies the size of a select item.
<readonly> is not valid in HTML. Use the disabled attribute. Claire Broadley Claire is seasoned technical writer, editor, and HTML… Read More...
Disables a drop-down list.
The language attribute of <select> is not valid HTML. Instead, use <script> with a valid type attribute. Claire Broadley Claire… Read More...
Triggers an event when the selection is changed.
Defines the order of selection when the tab key is pressed.
Triggers an event when a select item receives focus.
Do not use. The <spacer> element is obsolete in HTML 5. TYPE sets the type of spacer to use. TYPE… Read More...
Do not use. The <spacer> element is obsolete in HTML5. Claire Broadley Claire is seasoned technical writer, editor, and HTML… Read More...
Do not use. The <spacer> element is obsolete in HTML 5. Claire Broadley Claire is seasoned technical writer, editor, and… Read More...
Do not use. The <spacer> element is obsolete in HTML 5. Claire Broadley Claire is seasoned technical writer, editor, and… Read More...
Identifies the type of media contained within a <style> element. However, the only supported value is text/css, so the attribute is not needed.
Identifies the device or media that the styles contained in a <style> are designed to be applied to. Allows CSS styles to be optimized for a variety of devices and media formats.
Was used to specify whether or not borders should be applied to all table cells. This attribute has been deprecated in favor of CSS.
Was used to add padding between the contents of each table cell and the border or edge of the cell. This attribute has been deprecated and CSS should be used instead.
Was used to specify the distance between the individual cells of an HTML table. This element has been deprecated and CSS should be used to control table layout.
The width attribute of <table> is not supported in HTML. Use CSS to control the appearance of tables. Claire Broadley… Read More...
Was used to set the background color of an HTML table. This attribute has been deprecated. Use CSS to style tables.
Was used to specify the URL of an image to be set as the background for an HTML table. This element has been deprecated. Use CSS to style HTML tables.
Was used to align an HTML table to the left, right, or centered relative to the parent element. This attribute has been deprecated and CSS should be used to control the position of a table.
hspace is not a valid attribute of <table>. Use CSS instead. Claire Broadley Claire is seasoned technical writer, editor, and… Read More...
The height attribute of <table> is not valid in any version of HTML. Use CSS instead. Claire Broadley Claire is… Read More...
The frame attribute was used to define the visible borders of a table. It is now deprecated and should no longer be used.
Was used to specify the display of internal borders between rows and colums. This attribute has been deprecated. Use CSS to style table borders instead.
Was used to specify the color of table borders. This attribute has been deprecated. Use CSS to style table borders.
The summary attribute of <table> was designed to support non-visual HTML readers, such as screen readers. It is deprecated in… Read More...
Was used to specify the alignment of the contents of a single table data cell. This attribute has been deprecated. Use CSS to control alignment of the contents of a table data cell.
Was used to set the width of a table data cell to a value that would override the default width. This attribute has been deprecated. Use CSS to control layout of data cells in HTML tables.
Indicates how many columns a cell should take up.
Specifies the linked document, resource, or location.
Depreciated - do not use.
Specifies the context in which the linked resource will open.
Defines the title of a link, which appears to the user as a tooltip.
Specified the URL of an application code file to be used in an applet. The applet element has been deprecated.
Specified the location of a directory contain application code to be used in an applet element. The applet element has been deprecated.
Specified the display width of an applet panel. The applet has been deprecated.
Specified the display height of an applet panel. The applet element has been deprecated.
Was used to specify the alignment of an applet relative to the surrounding content. The applet element has been deprecated.
Was used to specify the amount of whitespace that should appear above and below an embedded <applet> element. Applets and the vspace attribute have been deprecated.
Specified the amount of horizontal space (margin) on both sides of an applet element. The applet element has been deprecated.
Specified the border around the applet panel. The applet element has been deprecated.
Defined the name of an applet. The applet element has been deprecated.
Specified the URL of a JAR (Java Archive) file containing the application code for the applet. The applet element has been deprecated.
Indicated whether an applet may access on-page JavaScript objects. The applet element has been deprecated.
Defines the URL of the linked document or resource.
Specifies alternative text for a clickable area in an image map.
In conjunction with the coords attribute, specifies the shape, size, and placement of a clickable area in an image map.
Defines the shape and size of a clickable area in an image map.
Defines the title text of the clickable area. The title text will appear as a tooltip in most browsers.
Specifies the context in which to open the linked resource.
Specified that an area of an image map did not link to another resource.
Specifies the base URL which will be used for all relative links in the current document.
Specifies the default target value for all anchor links in the current document.
Was used to set the base font size for a whole document. Deprecated. Use CSS instead.
Used to set the text color for a whole document. Deprecated. Use CSS instead.
Was used to set the base font face for a document. Deprecated. Use CSS instead.
Specified the URL of the audio source file for the deprecated <bgsound> element.
Specified whether the audio track defined in the deprecated <bgsound> element should loop.
Was used to set the background color on a document. Deprecated. Use CSS instead.
Was used to set the background color and image for the document. Deprecated. Use CSS instead.
Was used to style the text inside the body of the document. Deprecated. Use CSS.
Was used to style the background of a document. Deprecated. Use CSS instead.
Was used to set a margin above the body of a document. Deprecated. Use CSS.
Fires a script when the page has finished loading.
Fires a script when the visitor leaves the page.
Fires a script when the visitor focuses on the current page.
Was a proprietary attribute for the Frontpage system. Do not use.
Was used to toggle the display of scroll bars on a page, disabling the user's ability to scroll. Deprecated. You could use CSS to accomplish this, but you should not because it is a bad idea.
Was used to ensure that line breaks "cleared" floated or aligned elements above them. Deprecated.
Runs a script when a button is clicked.
Defines the name of the button, which is used for form inputs and labels.
Sets the initial value of the button element.
Disables the button. It cannot be clicked and usually appears gray.
Defines an keyboard shortcut for the button. As of HTML5, this is a global attribute that can be used on any element.
Determines the order of selection when the tab key is used.
Was used to control the horizontal alignment of a table caption. Deprecated. Use CSS instead.
Was used to control the vertical alignment of a table caption. Deprecated. Use CSS.
Specifies the number of natural vertical columns to be included in the <col> element.
Was used to control the alignment of text within table columns. Deprecated. Use CSS instead.
Was used to control the width of table columns. Deprecated. Use CSS instead.
Was used to control the background color of table columns. Deprecated. Use CSS instead.
Specifies the number of vertical table columns to be included in a column group.
Was used to control the text alignment within a column group in a table. Deprecated. Use CSS.
Was used to specify the width of a group of table columns. Deprecated. Use CSS instead.
Was used to specify the alignment of a div element. Deprecated. Use CSS instead.
Was used to specify a compact display style for a description list. Deprecated. Use CSS instead.
Specifies the URL of an application to be embedded.
Specifies the width of an embedded application panel.
Was used to control the alignment of an embedded application. Not a part of the HTML specification.
Was used to define the name of an embedded application. Not a part of the HTML specification.
Was used to indicate a download source for a plugin required in order to run the embedded application. Not a part of the HTML specification.
Was used as part of a proprietary specification for embedded applications. Not a part of the HTML specification.
Hides the element from view.
Was used to start embedded audio playback immediately. Not a part of the HTML specification.
Was used to loop playback of embedded media. Not part of the HTML specification.
Was used to specify the number of times an embedded media file should play. Not a part of the HTML specification.
Was used to specify the playback volume of an embedded application. Not a part of the HTML specification.
Was used to toggle the display of playback controls in embedded media. Not a part of the HTML specification.
Was used to toggle display of playback controls. Not a part of the HTML specification.
Was used to control sound in embedded media. Not part of the HTML specification.
Was used to indicate the starting playback position for embedded media. Not a part of the HTML specification.
Was used to specify the size of text. Deprecated. Use CSS instead.
Was used to specify font color. Deprecated. Use CSS instead.
Was used to specify a typeface. Deprecated. Use CSS instead.
Was used to specify the size of text. Deprecated. Use CSS instead.
Was used to indicate the weight (boldness) of text. Deprecated. Use CSS instead.
Specifies a URL to which the form's data is sent when submitted.
Tells the browser how to send form data to a web server.
The `name` attribute is deprecated when used with the `form` element. Use `id` instead.
The enctype attribute lets you specify an encoding type for your form.
Specifies the browser context in which the form's response should be displayed.
Runs a script when the Submit button is clicked.
Runs a script when the Reset button is clicked.
Defined the source URL for a frame. Frames are deprecated in HTML5.
Defined the name of a frame. Frames are deprecated in HTML5.
Was used to control scrolling behavior inside frames. Frames are deprecated in HTML5.
Was used to stop users from resizing frames within a browser window. Frames are deprecated in HTML5.
Was used to control the borders around frames. Frames are deprecated in HTML5.
Specified the color of a frame border. Frames are deprecated in HTML5.
Was used to control the margins of a frame. Frames are deprecated in HTML5.
Was used to control display columns in a frameset. Frames and framesets are deprecated in HTML5.
Was used to control borders between frames in a frameset. Frames are deprecated in HTML5.
Was used to specify the color of borders between frames in a frameset. Frames and framesets are deprecated in HTML5.
Was used to specify text alignment (justification) on headline elements. Deprecated in HTML5. Use CSS instead.
Was used to change the display of a horizontal rule form the default 3D style to a flatter 2D style. Deprecated. Use CSS to control the display of an element.
Was used to specify the height (thickness) of a horizontal rule. Deprecated. Use CSS instead.
Was used to specify the width of a horizontal rule. Deprecated in HTML5. Use CSS instead.
Was used to control the horizontal alignment of a horizontal rule. Deprecated. Use CSS instead.
Was used to control the display color of a horizontal rule. Deprecated. Use CSS instead.
Specifies the URL of a document to display in an iframe.
Specifies the name of an iframe.
Was used to specify URL containing a long description of an iframe. Deprecated in HTML5. Use CSS instead.
Was used to toggle the display of a border around an iframe. Deprecated in HTML5. Use CSS instead.
Was used to control the width of margins around an iframe. Deprecated in HTML5. Use CSS instead.
Was used to toggle scrolling on iframes. Deprecated in HTML5. Use CSS instead.
Was used to set the alignment of an inline frame relative to surrounding elements. Deprecated. Use CSS instead.
Was used to control the vertical spacing around an iframe. Deprecated in HTML5. Use CSS instead.
Specifies the URL of an image to be displayed.