Skip to main content Accessibility Feedback

Attributes & Properties


HTML elements have dozens of properties that you can access directly.

Some of them are read only, meaning you can get their value but not set it. Others can be used to both read and set values. You can find a full list on the Mozilla Developer Network.

let elem = document.querySelector('#main');

// Get the ID of the element
// returns "main"
let id =;

// Set the ID of the element = 'secondary';

// Get the parentNode of the element
// This property is read-only
let parent = elem.parentNode;

Join the Lean Web Club! Coaching. Courses. Coding resources. Get the skills, confidence, and support you need to learn front-end web development and achieve long-term success.

Find this useful? You can support my work by purchasing an annual membership.