HTML attributes are additional pieces of information that can be added to HTML tags to provide extra functionality or specify further details about the elements. They are used to modify the behavior and appearance of the elements on a web page.
Each HTML attribute has a specific name and a corresponding value, and they are added to an HTML tag as name-value pairs within the opening tag. For example, the "src" attribute is used to specify the source URL of an embedded content, such as an image, and its value would be the actual URL of the content.
HTML attributes can be used to specify various details about an element, such as its size, location, or behavior. For example, the "width" and "height" attributes can be used to specify the size of an image, while the "alt" attribute provides alternative text for an image for accessibility purposes.
HTML attributes are an important part of HTML and web development, and they provide additional functionalities and flexibility to the HTML tags, making it possible to create more dynamic and interactive web pages. Understanding the different HTML attributes and their uses is crucial for effective web development and designing engaging web pages.
Here is a list of some common HTML attributes with a brief explanation:
These are just some of the most common HTML attributes, and there are many more available. HTML attributes provide additional information and functionalities to HTML tags, making it possible to create more dynamic and interactive web pages.
Attribute | Description |
---|---|
accept | List of types the server accepts, typically a file type. |
accept-charset | List of supported charsets. |
accesskey | Keyboard shortcut to activate or add focus to the element. |
action | The URI of a program that processes the information submitted via the form. |
align | Specifies the horizontal alignment of the element. |
allow | Specifies a feature-policy for the iframe. |
alt | Alternative text in case an image can't be displayed. |
async | Executes the script asynchronously. |
autocapitalize | Sets whether input is automatically capitalized when entered by user |
autocomplete | Indicates whether controls in this form can by default have their values automatically completed by the browser. |
autofocus | The element should be automatically focused after the page loaded. |
autoplay | The audio or video should play as soon as possible. |
bgcolor | Background color of the element. |
border | The border width. |
buffered | Contains the time range of already buffered media. |
capture | From the Media Capture specification, specifies a new file can be captured. |
challenge | A challenge string that is submitted along with the public key. |
charset | Declares the character encoding of the page or script. |
checked | Indicates whether the element should be checked on page load. |
cite | Contains a URI which points to the source of the quote or change. |
class | Often used with CSS to style elements with common properties. |
code | Specifies the URL of the applet's class file to be loaded and executed. |
codebase | This attribute gives the absolute or relative URL of the directory where applets' .class files referenced by the code attribute are stored. |
color | This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format. |
cols | Defines the number of columns in a textarea. |
colspan | The colspan attribute defines the number of columns a cell should span. |
content | A value associated with http-equiv or name depending on the context. |
contenteditable | Indicates whether the element's content is editable. |
contextmenu | Defines the ID of a <menu> element which will serve as the element's context menu. |
controls | Indicates whether the browser should show playback controls to the user. |
coords | A set of values specifying the coordinates of the hot-spot region. |
crossorigin | How the element handles cross-origin requests |
csp Experimental | Specifies the Content Security Policy that an embedded document must agree to enforce upon itself. |
data | Specifies the URL of the resource. |
data-* | Lets you attach custom attributes to an HTML element. |
datetime | Indicates the date and time associated with the element. |
decoding | Indicates the preferred method to decode the image. |
default | Indicates that the track should be enabled unless the user's preferences indicate something different. |
defer | 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) |
disabled | Indicates whether the user can interact with the element. |
download | Indicates that the hyperlink is to be used for downloading a resource. |
draggable | Defines whether the element can be dragged. |
enctype | Defines the content type of the form data when the method is POST. |
enterkeyhint Experimental | The enterkeyhint specifies what action label (or icon) to present for the enter key on virtual keyboards. The attribute can be used with form controls (such as the value of textarea elements), or in elements in an editing host (e.g., using contenteditable attribute). |
for | Describes elements which belongs to this one. |
form | Indicates the form that is the owner of the element. |
formaction | Indicates the action of the element, overriding the action defined in the <form>. |
formenctype | If the button/input is a submit button (type="submit"), this attribute sets the encoding type to use during form submission. If this attribute is specified, it overrides the enctype attribute of the button's form owner. |
formmethod | If the button/input is a submit button (type="submit"), this attribute sets the submission method to use during form submission (GET, POST, etc.). If this attribute is specified, it overrides the method attribute of the button's form owner. |
formnovalidate | If the button/input is a submit button (type="submit"), this boolean attribute specifies that the form is not to be validated when it is submitted. If this attribute is specified, it overrides the novalidate attribute of the button's form owner. |
formtarget | If the button/input is a submit button (type="submit"), this attribute specifies the browsing context (for example, tab, window, or inline frame) in which to display the response that is received after submitting the form. If this attribute is specified, it overrides the target attribute of the button's form owner. |
headers | IDs of the <th> elements which applies to this element. |
height | Specifies the height of elements listed here. For all other elements, use the CSS height property. |
hidden | Prevents rendering of given element, while keeping child elements, e.g. script elements, active. |
high | Indicates the lower bound of the upper range. |
href | The URL of a linked resource. |
hreflang | Specifies the language of the linked resource. |
http-equiv | Defines a pragma directive. |
id | Often used with CSS to style a specific element. The value of this attribute must be unique. |
importance Experimental | Indicates the relative fetch priority for the resource. |
integrity | Specifies a Subresource Integrity value that allows browsers to verify what they fetch. |
intrinsicsize Deprecated | This attribute tells the browser to ignore the actual intrinsic size of the image and pretend it's the size specified in the attribute. |
inputmode | Provides a hint as to the type of data that might be entered by the user while editing the element or its contents. The attribute can be used with form controls (such as the value of textarea elements), or in elements in an editing host (e.g., using contenteditable attribute). |
ismap | Indicates that the image is part of a server-side image map. |
keytype | Specifies the type of key generated. |
kind | Specifies the kind of text track. |
label | Specifies a user-readable title of the element. |
lang | Defines the language used in the element. |
language Deprecated | Defines the script language used in the element. |
loading Experimental | Indicates if the element should be loaded lazily (loading="lazy") or loaded immediately (loading="eager"). |
list | Identifies a list of pre-defined options to suggest to the user. |
loop | Indicates whether the media should start playing from the start when it's finished. |
low | Indicates the upper bound of the lower range. |
manifest Deprecated | Specifies the URL of the document's cache manifest. |
max | Indicates the maximum value allowed. |
maxlength | Defines the maximum number of characters allowed in the element. |
minlength | Defines the minimum number of characters allowed in the element. |
media | Specifies a hint of the media for which the linked resource was designed. |
method | Defines which HTTP method to use when submitting the form. Can be GET (default) or POST. |
min | Indicates the minimum value allowed. |
multiple | Indicates whether multiple values can be entered in an input of the type email or file. |
muted | Indicates whether the audio will be initially silenced on page load. |
name | Name of the element. For example used by the server to identify the fields in form submits. |
novalidate | This attribute indicates that the form shouldn't be validated when submitted. |
open | Indicates whether the contents are currently visible (in the case of a <details> element) or whether the dialog is active and can be interacted with (in the case of a <dialog> element). |
optimum | Indicates the optimal numeric value. |
pattern | Defines a regular expression which the element's value will be validated against. |
ping | The ping attribute specifies a space-separated list of URLs to be notified if a user follows the hyperlink. |
placeholder | Provides a hint to the user of what can be entered in the field. |
playsinline | A Boolean attribute indicating that the video is to be played "inline"; that is, within the element's playback area. Note that the absence of this attribute does not imply that the video will always be played in fullscreen. |
poster | A URL indicating a poster frame to show until the user plays or seeks. |
preload | Indicates whether the whole resource, parts of it or nothing should be preloaded. |
readonly | Indicates whether the element can be edited. |
referrerpolicy | Specifies which referrer is sent when fetching the resource. |
rel | Specifies the relationship of the target object to the link object. |
required | Indicates whether this element is required to fill out or not. |
reversed | Indicates whether the list should be displayed in a descending order instead of an ascending order. |
role | Defines an explicit role for an element for use by assistive technologies. |
rows | Defines the number of rows in a text area. |
rowspan | Defines the number of rows a table cell should span over. |
sandbox | Stops a document loaded in an iframe from using certain features (such as submitting forms or opening new windows). |
scope | Defines the cells that the header test (defined in the th element) relates to. |
selected | Defines a value which will be selected on page load. |
size | 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. |
span | Define a merging count cell |
spellcheck | Indicates whether spell checking is allowed for the element. |
src | The URL of the embeddable content. |
srcset | One or more responsive image candidates. |
start | Defines the first number if other than 1. |
style | Defines CSS styles which will override styles previously set. |
tabindex | Overrides the browser's default tab order and follows the one specified instead. |
target | Specifies where to open the linked document (in the case of an <a> element) or where to display the response received (in the case of a <form> element) |
title | Text to be displayed in a tooltip when hovering over the element. |
translate | Specify whether an element's attribute values and the values of its Text node children are to be translated when the page is localized, or whether to leave them unchanged. |
type | Defines the type of the element. |
value | Defines a default value which will be displayed in the element on page load. |
width | For the elements listed here, this establishes the element's width. |
wrap | Indicates whether the text should be wrapped. |
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions