VOOZH about

URL: https://www.geeksforgeeks.org/html/html-dom-complete-reference/

⇱ HTML DOM Complete Reference - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML DOM Complete Reference

Last Updated : 12 Jul, 2025

HTML DOM (Document Object Model) is a programming interface that represents the elements of an HTML document in a tree-like structure.

  • Allows developers to change content and layout using JavaScript.
  • Enables dynamic updates and user interaction on websites.
  • Facilitates the addition, removal, or modification of HTML elements.

HTML DOM Attribute Object:

Methods:

Methods

Description

Return the attribute node from the NamedNodeMap object.
Return the node to the specified index.
Remove the node with the specified name in a named node object.

Properties:

Properties

Description

Returns a true if the Element has an attribute type of ID, otherwise, it returns a false
Get the number of items in a NodeList object.
It returns true if the element has a specified attribute, otherwise, it returns a false
Return the value of any attribute.

Console Object Methods:

Methods 

Description

Write a message for user on the console only if the expression evaluates to false
Clear the console and writes some message
Write the number of times the console.count() method is called.
Display an error message on the console
Create a group of messages in the console
Create a collapsed group of messages in the console.
To indicate the end of a group of messages in the console
Writing a message in the console.
It is used for writing a message in the console.
It is used for writing data in tabular form in the console view.
It is used to start a timer in the console view.
It is used to end a timer started by the console.time() method.
It is used to display the trace which represents how the code ended up at a certain point. 
It is used to write a warning message in the console. 

Document Object Properties:

Properties

Description

Return the currently active elements in the HTML document. 
Return the base Uniform Resource Identifier (URI) of the document.
It only returns the content present in the <body> Tag.
cookies are used by websites to keep track of user-specific information. 
Return the character encoding for the document at the time of parsing.
It is used to return the document Window Object
It is used to specify whether the document is editable or not. 
Return the doctype of any HTML document.
Return the documentElement as an Element Object
Detect the document mode used by the browser to render the current page.
Return the domain name of the website server that is loaded or running in the current document. 
Return the element that is currently in fullscreen.
Return the first occurrence of the head if multiple heads in the document
Return the collection of <img> elements in the document.
Returns the DOMImplementation object associated with the current document.
Returns the character encoding used for parsing the document.
Return the date and time of the current document that was last modified. 
Return the loading status of the current document. This property is used for read-only. 
Return the URI of the page that linked to the current page.
Returns whether strict error checking can be enforced on a document or not. 
It is used to sets the value of the title in the document.
Return a string that contains the complete URL of the current document. 

Methods

Description

Attaches an event handler to the specified element.
It is used to adopt a node from another document. 
It is used to close the output stream.
It is used to create an attribute with the specified name and returns the attribute object.
Create a comment node with some specified text. 
A new document fragment that can be inserted into any document can be created using the offscreen node.
The document.createElement() is a method used to create the HTML element. 
Creates an event object of the specified type. 
Create a TextNode which contains element node and a text node.
Execute a command specified by the user on the editable selected section. 
Check the document can be viewed in full screen mode or not.
Returns an element with a specified value.
Returns a collection of elements with a specified class name(s).
Returns collection of all elements of particular document by name.
Returns the collection of all the elements in the document with the given tag name.
Indicating whether an element or document has the focus or not. 
Copy of a node from another document and imports it to the current document. 
The normalize() method does not require any parameter.
Normalize an HTML document by remove any empty text nodes if exists.
The open() method allows you to write on a document.
Return the first element that matches a specified CSS selector(s) in the document.
Remove an event handler associated with the addEventListener() method
It is used to rename the nodes. 
It is used to write some content or JavaScript code in a Document.
It is used to write a document with additional property of newline character after each statement. 

Collection

Description

Return the collection of all <a> element in a HTML document.
Return a collection of all possible elements available in the HTML
Return the collection of all embedded elements.
Return the collection of all <form> elements in a HTML document.
Return the collection of all <a> and <area> elements with “href” attribute in a HTML document. 
Return the collection of all <script> element in HTML document. 

Properties

Description

Return the accesskey attribute of an element.
Returns the group of node attributes specified by NamedNodeMap objects. 
It counts only child element except for text and comment nodes. 
Returns a node’s child nodes as a nodeList object. 
Return HTMLcollection of all the child elements of the specified element.
Returns the class names of the element in the form of DOMTokenlist()
Return the value of an element’s class attribute.
Return the viewable height of an element in terms of the pixel.
Return the width of the left border to an element in terms of pixel.
Return the width of the top border to an element in terms of pixel.
 It is used to return the viewable width of a specific element
Return the value of dir attribute in an Element.
Return the firstchild Node of its parent node element. 
Return the first child of any node PreRequisites
Return the HTML content of an element
Returns the text content of a specified node and its descendants. 
Return a boolean where true means the content of an element is editable.
Return the last child of the specified node.
Return the last child element of the specified element or null if there is no last element.
Return the next node of the specified node as Node object 
Return the immediate next element of the specified element,
Return the name of the specified node as a string.
Find out the type of the node that we are referring to.
Its used to set or get the nodeValue in Any Html document. 
Returns the layout height of an element as an integer.
Returns the layout width of an element as an integer.
Returns the left position in pixels. 
Return the nearest ancestor of an element.
Return the top position which is relative to the top of the offsetParent element.
Returns the top-level document object of the node.
Return the parent node of the specified node as Node object. It is a read-only property. 
Returns the parent element of a particular child element. 
Return the previous node of the specified node as Node
Return the previous element of the same level of the given element.
It is used to return the height of an element.
It is used to return or set the number of pixels an element 
Return or set the number of pixels an element is scrolled vertically.
It is used to return the width of an element. 
It is used to return the tagname of the Element.
Return the text content of the specified node and all its descendants.
It is used to return the title of the HTML document 

Methods

Description

Attaches an event handler to the specified element.
Create a text node as the last child of the node. 
Remove the keyboard focus from the current element 
It is used to simulate the mouse click on an element. 
It is used to copy or clone a node on which the cloneNode() method is called. 
It is used to compare two nodes and it returns an integer
It is used to find whether the specified node is a descendant of the given node.
It is currently in a full-screen mode to be taken out of full-screen mode.
Remove the focus with the help of blur() method. 
It is used to get the value of the attribute of the element.
Return the attribute node with the specified name of an element, as an attribute object.
Returns the relative positioning to the viewport.
Returns a collection of elements with a specified class name(s).
Returns the collection of all the elements in the document with the given tag name.
Inserts the specified element at the specified position
Inserts HTML code into a specified position.
Inserts a a text into a specified position.
Insert a new node before the existing node as specified by the user. 
Return boolean true if the specified namespace is default otherwise, it returns boolean false
Checks whether the two nodes are equal or not. 
Checks whether the two nodes are same or not. 
Check the specified feature is supported by the specified node or not. 
Merge the adjacent text nodes with the first text node
Return the first element that matches a specified CSS selector(s) in the document.
Return a collection of an element’s child elements
Remove an attribute with specified name from the element.
Remove the specified attribute from the current element.
Remove a specified child node of the given element.
Remove an event handler associated with the addEventListener() method. 
Replace a child node with a new node within the given parent node. 
It is used to add the specified attribute node to an element.

Geolocation Object:

PropertiesDescription
Return the position and altitude of the device on Earth. 
Return the position of a device on Earth. 

History Object:

Methods

Description

It is used to load the previous URL in the history list.
It is used to load the next URL in the history list. 
It is used for loading a specific URL from the history list.

Properties

Description

Return the count of URLs in the history list of the current browser window.

DOM HTMLCollection:

Properties

Description

Return the collection of all HTML elements in a document.

Methods

Description

Return the content of the element at the given index of the collection of all HTML elements.
Return the element with having the specified ID, OR, name, or content 

Location Object

Properties

Description

Return the anchor part of a URL. 
Returns the hostname and port of a URL.
Return the hostname of the current URL.
Return the complete URL of the current page.
Return the protocol, hostname, and port number of a URL. 
Returns a string that represents the pathname of the URL.
Sets the port number of the current URL. 
Return the protocol or set the protocol of the current URL. 
Set or return the query part of URL including the question mark.

Methods 

Description

 It is used for loading a new document
It is used to reload the current document.
It is used to replace the current document with the specified one.

The Navigator Object:

Properties 

Description

Returning the code name of the browser. 
It is used for returning the name of the browser.
Returns a string that represents the version information of the browser. 
It returns true if cookies are enabled else it returns false. 
Return a geolocation object by the browser which can be used to locate a user’s position. 
It is used for returning the browser’s language version. 
Return  Boolean value which specifies whether a browser is in the online or offline mode. 
Return the platform for which the browser is compiled. 
Return the browser’s engine(product) name. 
It is used for returning the user-agent header’s value sent to the server by the browser.

Methods

Description

It is used for returning a Boolean value that specifies
This method would always return a Boolean false value.

Screen Object:

Properties

Description

It is used for returning the height of the user’s screen, in pixels.
It is used for returning the width of the user’s screen, in pixels.
Return the bit depth of the color palette for displaying images, in bits per pixel.
It is used for returning the total height of a user’s screen.
It  is used for returning the color resolution of the visitor’s screen.
It is used for returning the total width of a user’s screen. 

Style object:

Properties

Description

It is used to align the items of a flexible container 
Return the default alignment of items in a flexible container. 
Return the alignment for a selected item inside a flexible container
To animate transitions from one CSS style to another CSS style
Returns the delay after which the animation should start. 
Return the animation direction.
To set the time interval to complete one cycle of an animation. 
The animation is not playing or when an animation is finished or when there is a delay in animation
Return how many times an animation should be played. 
Returns a name for @keyframes animation. 
The time of transition between the styles to make transitions smooth. 
It is used to specify whether an animation is running or paused. 
Return the background of an element.
Return whether the background image should be fixed or scroll with the content. 
Return the background-color of an element.
Return the background image of an element. 
Return position of the background-image in an element. 
HTML DOM is used to set or return the CSS
Return the painting area of the background.
The background image is relative to in position. 
Return the size of the background image. 
Element visible or invisible when the element is not facing the screen.
It  is used to sets or returns the style of an element’s border.
Returns the three different border-bottom property such as border-bottom-width,etc.
Return the color of bottom border of an element.
Return the radius of the border of the bottom-left corner.
Set the style of the radius of the bottom-right corner of its border. 
Return the style of the bottom border of an element. 
Return the width of bottom border of an element. 
Returns the border of the table collapsed into a single border or not. 
Specifies the color of the element’s border. 
It is used for setting the borderImageSource, borderImageSlice,etc.
The border, image is to be painted is called the border-image space.
Return the borderImageRepeat property.
Specify the value of this property in terms of percentage, number or global values.
Return the image to be used instead of the styles given by the border-style property. 
Return the width of the border image. 
It is used to set or returns the three different 
Get the color to left border of element. 
Set or return the left border style of an element. 
Return the width of the left border of an element.
Return the four different borderRadius
Returns the three different border-right property
Return the style of right border of an element. 
Return the width of the right border of an element. 
Return the spacing between the cells in a table. 
Return the border style of an element.
Returns the three different border-top property 
Get the color of top border of element. 
Return the radius of the top left border of an element. 
Return the radius of the top right border of an element. 
Return the top border style of an element. 
Return the width of the top border of an element. 
Return the width of the border element.
Return the drop-shadow of an element. 
It is used when fitting elements into their desired position by automatically calculating their dimensions.
Return the position of the caption in a table. 
Get the position of the specific element relative to floating objects.
Return the visible part of a positioned element. 
Return the color of the text.
That defines the number of columns an element should be divided into.
Specifies how to fill a column(balanced or not).
Specifies the gap between the columns.
Sets the width, style, and color of the rule between columns.
Specifies the color of the rule between columns.
Determine the style of rule between columns.
Determine the width of the rule between the columns.
Set the width of the column & column count.
Specify how many columns an element should span across.
The counter should be incremented on each occurrence of a selector.
It  is used with the counterincrement property and the content property.
Return the type of cursor to display for the mouse pointer. 
Return the text direction of an element. 
Return the display type of an element. 
It is used to display borders and background for the empty cells. 
It is used to add visual effects or filter effects to images. 
Returns the length of the item, relative to rest of flexible items inside the same container. 
Return the initial length of a flexible item
Return the main-axis direction of the flexible items. 
It is used to specify the value for two different properties
An item will grow relative to the rest of the flexible items inside the same container. 
Set how the specific item can be shrink in relation to the remaining flexible items within the container. 
It is used to determine whether the flexible items should wrap or not. 
Returns the horizontal alignment of element.
 It is used to change the element’s font properties.
Return a list of Font-Family names and generic-family names for text in an element. 
Get the font size of characters in a word should appear. 
Get font style of an element dynamically.
It s used to set the font in capital letters.
Return how thick or thin characters in a word should appear. 
The font size if the first choice of font is not available. 
It is used to set or get height of an element dynamically.
Whether an element must necessarily create a new stacking context. 
It is used to align the items horizontally when they are not able to use all the available space. 
It is used for setting or returning the left position of a positioned element.
It is used to set the space between the characters.
It is used for setting or returning the distance between lines in a text. 
It is used to set up to three Properties 
Return an image as the list-item icon. 
Returns the position of the list-item marker.
It is used for setting or returning the list-item marker type. 
Returns the margin of an element.
Return the bottom margin of an element. 
Get the left margin of an element. 
Return the right margin of an element. 
Return the top margin of an element. 
Return the maximum height of an element. 
Return the maximum width of an element.
Return the minimum height of an element.
Return the minimum width of an element.
Return how an image or video element is resized to fit it’s container.
Return how an image or video would be positioned in their own content box. 
It is used to set opacity level for an element. 
The order of a flexible element relative to the rest of the flexible elements
The minimum number of lines in a paragraph split on the old page.
Return all outline properties in one declaration. 
Returns the color of the outline around an Element. 
It  is used for offsetting an outline and draw it beyond the border edge. 
Return the style of the outline around an element. 
Return the width of the outline around an element. 
It is used to specify the behavior of the content when it overflows the element box.
Specify the behavior of the content when it overflows an element’s left and right edges.
Specify the behavior of the content when it overflows an element’s top and bottom edges
It is used for setting or returning the padding of an element
It is used for setting or returning the bottom padding of an element. 
It  is used for setting or returning the left padding of an element. 
It is used for setting or returning the right padding of an element.
It is used for setting or returning the top padding of an element.
Returning the page-break behavior after an element in printing or print preview. 
Return the page-break-before characteristics before the specified element in HTML document.
Returning the page-break behavior inside an element in printing or print preview. 
It is used to determine how far an element is placed from the Z plane.
It is used to describe the exact position of a 3D element based on the x and y-axis.
Returns the type of positioning method used by the element.
It is used to represent the HTML < q > element.
It is used to specify whether an element is resizable in height and width by the user. 
Return the right position of a positioned element including padding, scrollbar, border, and margin. 
Return how a table and its cells, rows, and columns should be laid out. 
Return the length of the space used in place of the tab character.
It is pretty much similar to the text-align property in the CSS.
set the alignment of the last line of the text.
It is used to set one or more decorations for a text.
Set the color of the text-decoration like underlines, overlines, etc.
It is used to set the decoration for a line
It is used to set the line.
It is used for indentation of the first line in each block of text. 
It is used to specify the behavior of the text when it overflows the containing element box. 
It is used to set the shadow effects for text. 
Return the capitalization of text.
Return the top position of a positioned element including padding, scrollbar,etc.
It is used to transform the object. The transform property allows to rotate, scale, move, etc.
This position is described using co-ordinate geometry using x-axis and y-axis. 
Return, the different ways nested elements use for their rendering in 3D space.
It is used to change the appearance of any DIV element. 
Set the name of the CSS property for the transition effect. 
Return the length of time(in seconds or milliseconds) to complete the transition effect. 
Allows a transition effect to change speed over its duration. 
Time in seconds or milliseconds when execution of transition starts. 
It is used with direction property to determine how multi-directional text is displayed.
Return whether the text can be selected by the user or not.
Return the vertical alignment of the content in an element. 
It is used to set the visibility for an element. 
Return the width of an element which can be block-level elements or elements with fixed position. 
Return the word-break property. 
It is used to set the spacing between words
Return whether long words should be broken to wrap around to the next line.
Return the stack order of a positioned element.

Window Object:

Properties

Description

Return a value that indicates whether the referred window is closed or not.
Return the default text in the status bar at the bottom side of the browser.
Returns the iframe element in which the window is embedded or stored.
Return the frame element in the form of an array object.
Returning the height of a window’s content area. 
Returning the width of a window’s content area.
Returning the number of <iframe> elements in the current window. 
Properties allow you to store value pairs in web browsers using objects.
It is used for setting or returning the name of a window. 
Return the reference of newly created windows.
It is used for returning the outer height of the browser window. 
It is used for returning the outer width of the browser window. 
It is used for returning the pixels of the current document 
Returns the parent window of the current window. 
Returning the ‘x’ or horizontal coordinate of a window relative to a screen. 
Returning the ‘y’ or vertical coordinate of a window relative to a screen. 
Returning the ‘x’ or the horizontal coordinates of a window relative to the screen. 
Returning the ‘y’ or the vertical coordinates of a window relative to the screen.
It is used for saving key/value pairs in a web browser. 
It is used for returning the current window. 
Return the text in the status bar at the bottom of the browser. 
Return the topmost browser window of a current window.

Methods

Description
It is used to display an alert box. 
It is used for decoding a base-64 encoded string.
Remove focus from the current window.
It is used to focus on the new open window.
It is used for encoding a string in base-64 format.
Set by the setTimeout()function before that.
Clears the interval which has been set by the setInterval() function before that.
Display a dialog box with an optional message and two buttons, OK and Cancel.
Get all the computed CSS property and values of the specified element.
Moving a window with a specified number of pixels relative to its current coordinates. 
It is used in the window to moves the window from the left and top coordinates.
It is used to open the web pages into a new window or a new tab. 
Depends on the browser settings and the values that are assigned to the parameter. 
The print() method prints the contents of the current window.
Display a dialog box with an optional message prompting the user to input some text.
Resize a window by the specified amount, relative to its current size. 
Resize a window to the specified width and height. 
Scroll to a particular set of coordinates in the document. 
Executes a function, after waiting a specified number of milliseconds. 
 Repeats a given function at every given time interval. 
Loading resources in the current browsing context, similar to the browser’s stop button. 

Storage Object:

Methods

Description

Return the name of the key with the specified index.
It is used to retrieve the storage object which is specified by the user.
It is used to set the storage object item which is specified by the user. 
It is used to remove the specified storage object item.
Removes all the Storage Object items for the current domain. 

Properties

Description

lengthReturn the number of items stored in the Storage Object.

Best Practices for HTML DOM

  • Use getElementById() for Performance: Access elements by their id for faster and more efficient DOM manipulation.
  • Minimize DOM Manipulation: Batch updates to the DOM to reduce reflows and improve performance.
  • Avoid Inline JavaScript: Use external JavaScript files to keep code organized and maintainable.
  • Add Event Listeners Dynamically: Use addEventListener instead of inline event attributes to separate behavior from structure.
Comment
Article Tags: