0% found this document useful (0 votes)
5 views2 pages

HTML Attributes Cheat Sheet

This document is a comprehensive cheat sheet for HTML attributes, categorized into Basic Global Attributes, Image Attributes, Link & Anchor Attributes, Form & Input Attributes, and Media & Audio/Video Attributes. Each category lists key attributes along with their descriptions and examples. It serves as a quick reference for developers to understand and utilize various HTML attributes effectively.

Uploaded by

gokila.digitaly
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

HTML Attributes Cheat Sheet

This document is a comprehensive cheat sheet for HTML attributes, categorized into Basic Global Attributes, Image Attributes, Link & Anchor Attributes, Form & Input Attributes, and Media & Audio/Video Attributes. Each category lists key attributes along with their descriptions and examples. It serves as a quick reference for developers to understand and utilize various HTML attributes effectively.

Uploaded by

gokila.digitaly
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HTML Attributes Cheat Sheet

Basic Global Attributes


Attribute Description Example

id Unique identifier for an element <p id="intro">Welcome</p>

class Assigns a class name (used for CSS/JS) <div class="box"></div>

style Inline CSS styling <h1 style="color:red;">Hello</h1>

title Tooltip text when mouse hovers <abbr title="HyperText Markup Language">HTML</abbr>

lang Language of the element’s content <html lang="en">

dir Text direction (ltr, rtl) <p dir="rtl">■■■■■</p>

hidden Hides the element <p hidden>This is hidden</p>

tabindex Navigation order for keyboard tabbing <input tabindex="1">

accesskey Shortcut key to focus an element <button accesskey="h">Help</button>

draggable Allows element to be dragged (true / false) <p draggable="true">Drag me</p>

spellcheck Enable/disable spell checking <textarea spellcheck="false"></textarea>

Image Attributes
Attribute Description Example

src File path/URL of the resource <img src="[Link]">

alt Alternate text if image can’t load <img src="[Link]" alt="Company Logo">

width Width of element <img src="[Link]" width="300">

height Height of element <img src="[Link]" height="200">

loading Lazy-load image (lazy/eager) <img src="[Link]" loading="lazy">

Link & Anchor Attributes


Attribute Description Example

href URL to navigate to <a href="[Link]

target Where to open the link (_blank, _self) <a href="[Link]" target="_blank">New Tab</a>

download Download linked file <a href="[Link]" download>Download</a>

rel Relationship between current and linked doc <a href="[Link]" rel="nofollow">Link</a>

Form & Input Attributes


Attribute Description Example

type Input type (text, password, email) <input type="email">


name Name for form submission <input name="username">

value Default value <input value="John">

placeholder Hint text inside field <input placeholder="Enter your name">

required Field must be filled <input required>

readonly Cannot edit value <input value="Fixed" readonly>

disabled Disables element <button disabled>Submit</button>

checked Pre-select checkbox/radio <input type="checkbox" checked>

selected Pre-select option <option selected>India</option>

multiple Allow multiple selections <select multiple>

maxlength Max characters allowed <input maxlength="10">

pattern Regex validation pattern <input pattern="[0-9]{3}">

autocomplete Turn autocomplete on/off <input autocomplete="off">

min / max Minimum / maximum value <input type="number" min="1" max="10">

step Step interval for numbers <input type="number" step="2">

Media & Audio/Video Attributes


Attribute Description Example

controls Show player controls <video controls>

autoplay Play automatically <video autoplay>

loop Repeat media <audio loop>

muted Start muted <video muted>

poster Image shown before playing <video poster="[Link]">

You might also like