HTML Attributes You Must Remember

Core HTML Attributes

Understanding common configuration fields for styling, identity, state, and routing.

Attributes configure elements or adjust their behavior. They are written as name="value" inside the opening tag.

Primary Attributes

  • id: Unique identifier across the entire document page.
  • class: Non-unique identifier for stylesheet matching.
  • href / src: Path coordinates for links and images.
  • alt: Alternate text descriptions.
  • title: Hover tooltip description.
  • style: Inline CSS formatting code.
  • type: Configuration type (buttons, inputs).
  • name / value: Form field parameters sent to server.
  • placeholder: User input prompt text.
  • required / disabled / readonly: State markers.
  • checked / selected / multiple: Selectors.
  • target: Window selector (anchors).
  • action / method: Form dispatch directions.
  • for: Label references.

Example

html
<input
type="text"
placeholder="Enter Name"
required>

Interview questions

Sign in to save

What is the difference between attributes and properties in the DOM?

Attributes are defined in the HTML markup (source code) and are always strings. Properties are defined in the DOM tree (JavaScript objects) and can have any data type (boolean, object, etc.). Updating a property changes the live state; updating an attribute changes the initial configuration.

Practice

Write a disabled text input that holds the value 'Locked' and is marked required.

Hint: Set <input type='text' value='Locked' disabled required>.