HTML Attributes Cheat Sheet
1. Core Attributes
- id: Specifies a unique ID for the element
- class: Specifies one or more class names for styling or scripting
- style: Specifies inline CSS styles
- title: Specifies extra information (tooltip)
2. Global Attributes
- accesskey: Specifies a keyboard shortcut
- contenteditable: Specifies if the content is editable
- data-*: Used to store custom data
- dir: Direction of the text ('ltr' or 'rtl')
- draggable: Specifies whether the element is draggable
- hidden: Hides the element
- lang: Specifies the language of the element
- spellcheck: Specifies if spell checking is allowed
- tabindex: Specifies the tab order of an element
- translate: Indicates whether the content should be translated
3. Event Attributes
- onclick: Triggered when element is clicked
- onmouseover: Triggered on mouse hover
- onchange: Triggered when form element value changes
- onkeydown: Triggered when a key is pressed
- onload: Triggered when the page or image loads
4. Form Attributes
- action: Defines where to send form-data
- method: HTTP method to use (GET or POST)
- type: Specifies type of input (text, email, etc.)
- name: Specifies the name of a form control
HTML Attributes Cheat Sheet
- value: Default value for the form control
- placeholder: Provides placeholder text
- required: Specifies that input must be filled out
- readonly: Makes the input field non-editable
- disabled: Disables the input element
5. Media Attributes
- src: Source file URL
- alt: Alternative text for image
- width/height: Specifies the size of media
- controls: Displays media controls
- autoplay: Media starts playing automatically
- loop: Plays media in a loop
- muted: Mutes the media
6. Anchor Attributes
- href: Specifies the URL
- target: Specifies where to open the link
- rel: Specifies the relationship between linked docs
- download: Forces download of linked resource
7. Boolean Attributes
- checked: Specifies that an element is pre-selected
- disabled: Specifies that an element is disabled
- readonly: Specifies that an element is read-only
- autofocus: Specifies that an element should get focus on page load
- required: Specifies that an element must be filled out