
| List of Attributes in HTML | ||
| Attribute | Belongs to | Description |
| accept | <input> | Indicates the kinds of files the server can receive (applicable solely to type="file"). |
| accept-charset | <form> | Defines the character encodings to be employed for submitting the form. |
| accesskey | Global Attributes | Specifies a shortcut key to activate/focus an element |
| action | <form> | Specifies where to send the form-data when a form is submitted |
| align | Not supported in HTML 5. | Specifies the alignment according to surrounding elements. Use CSS instead |
| alt | <area>, <img>, <input> | Specifies an alternate text when the original element fails to display |
| Asy nc | <script> | Specifies that the script is executed asynchronously (only for external scripts) |
| autocomplete | <form>, <input> | Specifies whether the <form> or the <input> element should have autocomplete enabled |
| autofocus | <button>, <input>, <select>, <textarea> | Specifies that the element should automatically get focus when the page loads |
| autoplay | <audio>, <video> | Specifies that the audio/video will start playing as soon as it is ready |
| bgcolor | Not supported in HTML 5. | Specifies the background colour of an element. Use CSS instead |
| border | Not supported in HTML 5. | Specifies the width of the border of an element. Use CSS instead |
| charset | <meta>, <script> | Specifies the character encoding |
| checked | <input> | Indicates that an <input> element should be already chosen when the page starts loading (for type="checkbox" or type="radio"). |
| cite | <blockquote>, <del>, <ins>, <q> | Specifies a URL which explains the quote/deleted/inserted text |
| class | Global Attributes | Specifies one or more classnames for an element (refers to a class in a style sheet) |
| colour | Not supported in HTML 5. | Specifies the text colour of an element. Use CSS instead |
| cols | <textarea> | Specifies the visible width of a text area |
| colspan | <td>, <th> | Specifies the number of columns a table cell should span |
| content | <meta> | Gives the value associated with the http-equiv or name attribute |
| contenteditable | Global Attributes | Specifies whether the content of an element is editable or not |
| controls | <audio>, <video> | Indicates that audio/video controls should appear, like a play/pause button, and so on. |
Also Read: List of All HTML Tags You’ll Find as a Web Developer!
| Main root | |
| Element | Description |
| <html> | It stands for the main part (top-level element) of an HTML document, so it's also called the root element. Every other element should be children of this element. |
| Document Metadata | |
| Element | Description |
| <base> | Specifies the foundational URL to be used for all relative URLs in a document. Only one element of this kind is allowed in a document. |
| <head> | Includes machine-readable details (metadata) regarding the document, such as its title, scripts, and style sheets. |
| <link> | Describes connections between the present document and an outside source. This part is frequently employed to connect with CSS but is also utilised to set up site icons (including "favicon" style icons and icons for the home screen and applications on mobile devices) and various other purposes. |
| <meta> | Represents metadata that cannot be represented by other HTML meta-related elements, like <base>, <link>, <script>, <style> and <title>. |
| <style> | Holds style details for a document or a section of a document. It consists of CSS, which is put on the content of the document that includes this element. |
| <title> | Defines the document's title that is shown in a browser's title bar or a page's tab. It only contains text; tags within the element are ignored. |
| Sectioning root | |
| Element | Description |
| <body> | represents the content of an HTML document. There can be only one such element in a document. |
| Content sectioning | |
| Element | Description |
| <address> | Indicates that the enclosed HTML provides contact information for a person or people, or for an organisation. |
| <article> | Represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication). Examples include a forum post, a magazine or newspaper article, a blog entry, a product card, a user-submitted comment, an interactive widget or gadget, or any other independent item of content. |
| <aside> | Represents a portion of a document whose content is only indirectly related to the document's main content. Asides are frequently presented as sidebars or call-out boxes. |
| <footer> | Represents a footer for its nearest ancestor sectioning content or sectioning root element. A <footer> typically contains information about the author of the section, copyright data, or links to related documents. |
| <header> | Represents introductory content, typically a group of introductory or navigational aids. It may contain some heading elements but also a logo, a search form, an author name, and other elements. |
| <h1>, <h2>, <h3>, <h4>, <h5>, <h6> | Represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest. |
| <hgroup> | Represents a heading grouped with any secondary content, such as subheadings, an alternative title, or a tagline. |
| <main> | Represents the dominant content of the body of a document. The main content area consists of content that is directly related to or expands upon the central topic of a document, or the central functionality of an application. |
| <nav> | Represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes. |
| <section> | Represents a generic standalone section of a document, which doesn't have a more specific semantic element to represent it. Sections should always have a heading, with very few exceptions. |
| <search> | Represents a part that contains a set of form controls or other content related to performing a search or filtering operation. |
Also Read: What is AngularJS? A Complete Guide for Beginners to Master in 2024
In this case, the for attribute in the <label> element refers to the id attribute of the <input> element, creating a connection between the label and the form input field.
Also Read: C++ Game Development: How Is C++ Used in Game Development?
, src and alt are attributes, each serving a specific purpose like specifying the image source and providing alternative text.