In this article, I’m going to teach the DOM methods.

Accessing HTML elements via class

If you want to access your HTML element and add changes to it the one approach is accessing by its class name.

HTML paragraph tag
accessing element by class name

Accessing HTML elements via tag name

Accessing HTML elements by tag name is ideal to the previous method just has a subtle difference that we change ClassName to TagName.

Accessing HTML elements via ID

If you want to access your HTML element via ID you can use getElementById(id) and getElementsById(id).

Accessing HTML elements via query selector

One of the modern and easy approaches to access every kinda HTML element such as ID,CLASS,and Tag we use document.querySelector(id or classsname or tags). This is one of the common approaches that every developer use in their day to day coding.

accessing HTML elements via querySelector
querySelectorAll

I am a web developer who writes web development content for you to make web development easier