Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

HTML Attributes Complete Reference - GeeksforGeeks.

pdf
Saved to Dropbox • 25-Jan-2024 at 7:13 AM

Courses Tutorials HTML/CSS JavaScript M


90% Refund @Courses Free HTML Course Tags Attributes Global Attributes Event Attributes HTML DOM DOM Audio/Video HTML 5 SVG Canvas MathML

Explore Our Geeks


Community
HTML Attributes Complete Reference Trending in News View More

Read Courses Jobs How To Earn Money Part-Time?


Share Your Experience
10 Best AI 3D Generators in 2024

HTML Tutorial HTML Attributes: HTML attributes are the special words placed inside Top 10 Free Midjourney Prompt
Generator [2024]
the opening tags and used to define the characteristics of an HTML
HTML Introduction Top 10 Free AI Writing Tools for Content
element. The HTML attributes contain two parts, attribute name, and Creators
its value. The attribute pairs (attribute_name, attribute_value) are 10 Best Free AI Art Generators to Create
HTML Editors
separated using equal (=) operator. The attribute value is closed inside Image From Text [Free & Paid]

HTML Basics double quotes (” “).

HTML Comments
The complete list of HTML attributes are given below:

Example: This example shows the basic use of HTML attributes.


HTML Elements

HTML
HTML Attributes

<!DOCTYPE html>
HTML Heading <html>
<body>
<center>
HTML Paragraphs
<h1 style="color:green;font-style:italic;">
GeeksForGeeks
HTML Text Formatting </h1>
<h2 style="color:green;font-style:italic;">
maxlength attribute
HTML Quotations </h2>
<form action="">
HTML Colors Username:
<input type="text" name="username" maxlength="12">
<br><br>
HTML Links
Password:
HTML Images <input type="text" name="password" maxlength="10">
<br><br>

HTML Favicon <input type="submit" value="Submit">


</form>
</center>
</body>
</html>

Output:
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood
Got It !
our Cookie Policy & Privacy Policy

HTML Attributes: The complete list of HTML attributes are given


below. is used to set visible border width to most HTML elements
within the body.

Attributes: Description Example

This attribute can be used with


accept Try
<input> element only.

Define character encoding and is


accept-charset Try
used for form submission.

The keyboard shortcuts to


accesskey Try
activate/focus specific elements.

Specify where the form data is to


action be sent to the server after Try
submission of the form.

Specify the alignment of text


align Try
content of The Element.

Show or display something if the


alt Try
primary attribute

Only works for external scripts


async (and used only in when src Try
attribute is present ).

Specify whether the input field


autocomplete has autocompleted would be on Try
or off.

The audio/video should


autoplay automatically start playing when Try
web page is loaded.

The element should get focused


autofocus when the page loads. It is a Try
boolean attribute.

Set the background color of an


bgcolor Try
HTML element.

Set visible border width to most


border Try
HTML elements within the body.
charset Define character encoding. Try

Indicate whether an element


checked should be checked when the page Try
loads up. It is a Boolean attribute.

Specify the URL of the document


that explains the quotes, message
cite Try
or text which describes why the
text was inserted.

Specifies one or more class names


Class Try
for an HTML element.

The number of columns a cell


cols Try
should span.

HTML specifies the number of


colspan Try
columns a cell should span.

The values that are related to the


content Try
http-equiv or name attribute.

Specify whether the content


contenteditable present in the element is editable Try
or not.

It is a Boolean attribute and also


controls Try
new in HTML5

Specify the coordinate of an area


coords Try
in an image-map

Specify the URL of the Embedded


data Try
file of the Object.

Specific to HTML5 and you can


data-* use the data-* attribute on all Try
HTML elements.

Specify the date and time of the


datetime Try
inserted and the deleted text.

Specify that the track will be


enabled if the user’s preferences
default Try
do not indicate that another track
would be more appropriate.

Executed when the page has


defer Try
finished parsing.

The text direction of the element


dir Try
content.

Enable the text direction of the


dirname input and the Textarea Field after Try
submitting the form.
The disabled attribute in HTML
disabled indicates whether the element is Try
disabled or not.

Download the element when the


download Try
user clicks on the hyperlink

Specify whether an element is


draggable Try
draggable or not.

Specify whether the dragged data


dropzone is copied, moved, or linked when it Try
is dropped on any element.

That data will be present in the


enctype form and should be encoded Try
when submitted to the server.

For Attribute is used in both the


for <label> and the <output> Try
element.

That the element can contain one


form Try
or more forms

Specify where to send the data of


the form. After submission of the
formaction Try
form, the formaction attribute is
called.

The HTML headers attribute


headers specifies one or additional header Try
cells a table cell is expounded to.

height attribute is used to specify


height Try
the height of the Element.

The hidden attribute in HTML is


hidden used to define the visibility of Try
elements.

The range where the value of


high gauge is considered to be of high Try
value.

It is used to specify the URL of the


href Try
document.

The language for a linked


hreflang document. It is used only when Try
the href attribute is set.

Provide header information or


http-equiv Try
value of the content Attribute.

It is used by CSS and JavaScript to


Id perform a certain task for a unique Try
element.

The HTML ismap attribute is a


ismap Try
boolean attribute.

The kind of track. This attribute is


kind Try
only used in <Track> element.

The title of the Text Track is used


label by the browser when listing Try
available text tracks.

Specify the language of the


lang Try
element content.

List of pre-defined options for an


list <input> element to suggest the Try
user.

Restart the audio and video again


loop and again after finishing it. It Try
contains the Boolean value.

The range where the value of


low Try
gauge is considered to be low.

Specifies the maximum value of


max Try
an element.

The maximum number of


maxlength characters in the <input> element. Try
Its default value is 524288.

Specify the media or device the


media coupled document is optimized Try
for.

The HTTP method is used to send


method Try
data while submitting the form.

Specify the lower bound of the


min Try
gauge.

Allowed to select more than one


multiple value that is present in an Try
element.

The audio output of the video is


muted Try
muted, it is a Boolean attribute.

name Specify a name for the element. Try

That the form-data should not be


novalidate validated when submitting the Try
form.

That moment when the element


onblur Try
loses focus.

The user copied the content


oncopy Try
present in an element.

The user cut or delete the content


oncut that has been present in the Try
element.

when a user presses a key on the


onkeypress Try
Keyboard.

Order of events occurs related to


onmousedown Try
the onmousedown event.

This onscroll attribute works


onscroll when an element scrollbar is Try
being scrolled.

The optimum attribute in HTML


optimum indicates the optimal numeric Try
value for the gauge.

Specifies a short hint that


pattern describes the expected value of Try
an input field/text area.

Specifies a short hint that


placeholder describes the expected value of Try
an input field/text area.

Specify that the text written in


readonly input or text area Element is read- Try
only.

Specify that the input element


required must be filled out before Try
submitting the Form.

Ordered the list in Descending


reversed Order(9, 8, 7, 6 …..) instead of Try
ascending order(1, 2, 3 ….)

The number of visible text lines


rows for the control i.e the number of Try
rows to display.

The number of rows a cell should


rowspan Try
span.

Specify which option should be by


selected default selected when the page Try
loads.

Specify the initial width for the


size input field and a number of visible Try
rows for the select element.
Applied to HTML forms using the
spellcheck Try
spellcheck attribute.

Specify the language of the track


srclang Try
text.

The start value for numbering the


start Try
individual list item.

Set the discrete step size of the


step Try
<input> element.

There are 3 ways of implementing


style Try
style in HTML.

When the tab button is used for


tabindex Try
navigating.

Specify where to open the linked


target Try
document.

Specify extra information about


title Try
the element.

Specify whether the content of an


translate Try
element is translated or not.

Specify the value of the element


value Try
with which it is used.

Specify in which manner the text


wrap is to be wrapped in a text area Try
when a form is submitted.

Learn to code easily with our course Coding for Everyone. This course
is accessible and designed for everyone, even if you're new to coding.
Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to


upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable
prices, all geared towards accelerating your growth in a time-bound
manner. Join the millions we've already empowered, and we're here to
do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete


90% in 90 days, and save 90% cost click here to explore.

Last Updated : 21 Nov, 2023 39

Previous Next

HTML Tags - A to Z List HTML Global Attributes


Share your thoughts in the comments Add Your Comment

Similar Reads

HTML Event Attributes Complete Reference

HTML DOM Complete Reference

HTML Canvas Complete Reference

HTML DOM Audio/Video Complete Reference

How to remove all attributes of an HTML element using jQuery ?

HTML DOM attributes Property

HTML Global Attributes

Difference between 'hidden' and 'aria-hidden' attributes in HTML


Why are dashes preferred for CSS selectors / HTML attributes ?

What is the difference between properties and attributes in HTML?

Complete Tutorials

SVG Tutorial

HTML Canvas Tutorial

HTML Tutorial

JavaScript Project Ideas with Source Code

Onsen UI

GeeksforGeeks

Article Tags : HTML-Attributes , HTML , Web Technologies

Additional Information

Company Explore Languages DSA Data Science & HTML & CSS
A-143, 9th Floor, Sovereign About Us Job-A-Thon Hiring Python Data Structures ML HTML
Corporate Tower, Sector-136,
Legal Challenge Java Algorithms Data Science With CSS
Noida, Uttar Pradesh - 201305
Careers Hack-A-Thon C++ DSA for Beginners Python Web Templates

In Media GfG Weekly PHP Basic DSA Data Science For CSS Frameworks
Contest Problems Beginner
Contact Us GoLang Bootstrap
Offline Classes DSA Roadmap Machine Learning
Advertise with us SQL Tailwind CSS
(Delhi/NCR) Tutorial
GFG Corporate R Language Top 100 DSA SASS
DSA in JAVA/C++ Interview ML Maths
Solution Android Tutorial LESS
Master System Problems Data Visualisation
Placement
Design Tutorials Archive Tutorial Web Design
Training Program DSA Roadmap by
Master CP Sandeep Jain Pandas Tutorial
Apply for Mentor
GeeksforGeeks All Cheat Sheets NumPy Tutorial
Videos NLP Tutorial
Geeks Community Deep Learning
Tutorial

Python Computer DevOps Competitive System Design JavaScript

Python Science Git Programming High Level Design JavaScript


Programming GATE CS Notes AWS Top DS or Algo for Low Level Design Examples
Examples CP TypeScript
Operating Systems Docker UML Diagrams
Django Tutorial Top 50 Tree ReactJS
Computer Kubernetes Interview Guide
Python Projects Network Top 50 Graph NextJS
Azure Design Patterns
Python Tkinter Database Top 50 Array AngularJS
GCP OOAD
Web Scraping Management Top 50 String NodeJS
DevOps Roadmap System Design
OpenCV Python System
Top 50 DP Bootcamp Lodash
Tutorial So!ware
Top 15 Websites Interview Web Browser
Python Interview Engineering
for CP Questions
Question Digital Logic
Design

Engineering Maths

NCERT School Commerce Management UPSC Study SSC/ BANKING


Solutions Subjects Accountancy & Finance Material SSC CGL Syllabus

Class 12 Mathematics Business Studies Management Polity Notes SBI PO Syllabus

Class 11 Physics Indian Economics HR Managament Geography Notes SBI Clerk Syllabus

Class 10 Chemistry Macroeconomics Income Tax History Notes IBPS PO Syllabus

Class 9 Biology Microeconimics Finance Science and IBPS Clerk

Class 8 Social Science Statistics for Economics Technology Notes Syllabus

Complete Study English Grammar Economics Economy Notes SSC CGL Practice

Material Ethics Notes Papers

Previous Year
Papers

Colleges Companies Preparation Exams More Tutorials Write & Earn

Indian Colleges IT Companies Corner JEE Mains So!ware Write an Article


Admission & So!ware Company Wise JEE Advanced Development Improve an Article
Campus Development Preparation So!ware Testing
GATE CS Pick Topics to
Experiences Companies Preparation for NEET Product Write
List of Central Artificial SDE Management
UGC NET Share your
Universities - In Intelligence(AI) Experienced SAP Experiences
India Companies Interviews SEO - Search Internships
Colleges in Delhi CyberSecurity Internship Engine
University Companies Interviews Optimization
IIT Colleges Service Based Competitive Linux
NIT Colleges Companies Programming Excel
IIIT Colleges Product Based Aptitude
Companies Preparation
PSUs for CS Puzzles
Engineers

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

You might also like