Menu
×
   ❮     
HTMLCSSJAVASCRIPTSQLPYTHONJAVAPHPHOW TOW3.CSSCC++C#BOOTSTRAPREACTMYSQLJQUERYEXCELXMLDJANGONUMPYPANDASNODEJSDSATYPESCRIPTANGULARGITPOSTGRESQLMONGODBASPAIRGOKOTLINSASSVUEGEN AISCIPYCYBERSECURITYDATA SCIENCEINTRO TO PROGRAMMINGBASH

JS Tutorial

JS HOMEJS IntroductionJS Where ToJS OutputJS StatementsJS SyntaxJS CommentsJS VariablesJS LetJS ConstJS OperatorsJS ArithmeticJS AssignmentJS Data TypesJS FunctionsJS ObjectsJS Object PropertiesJS Object MethodsJS Object DisplayJS Object ConstructorsJS EventsJS StringsJS String MethodsJS String SearchJS String TemplatesJS NumbersJS BigIntJS Number MethodsJS Number PropertiesJS ArraysJS Array MethodsJS Array SearchJS Array SortJS Array IterationJS Array ConstJS DatesJS Date FormatsJS Date Get MethodsJS Date Set MethodsJS MathJS RandomJS BooleansJS ComparisonsJS If ElseJS SwitchJS Loop ForJS Loop For InJS Loop For OfJS Loop WhileJS BreakJS IterablesJS SetsJS Set MethodsJS MapsJS Map MethodsJS TypeofJS Type ConversionJS DestructuringJS BitwiseJS RegExpJS PrecedenceJS ErrorsJS ScopeJS HoistingJS Strict ModeJS this KeywordJS Arrow FunctionJS ClassesJS ModulesJS JSONJS DebuggingJS Style GuideJS Best PracticesJS MistakesJS PerformanceJS Reserved Words

JS Versions

JS VersionsJS 2009 (ES5)JS 2015 (ES6)JS 2016JS 2017JS 2018JS 2019JS 2020JS 2021JS 2022JS 2023JS 2024JS IE / EdgeJS History

JS Objects

Object DefinitionsObject PrototypesObject MethodsObject PropertiesObject Get / SetObject Protection

JS Functions

Function DefinitionsFunction ParametersFunction InvocationFunction CallFunction ApplyFunction BindFunction Closures

JS Classes

Class IntroClass InheritanceClass Static

JS Async

JS CallbacksJS AsynchronousJS PromisesJS Async/Await

JS HTML DOM

DOM IntroDOM MethodsDOM DocumentDOM ElementsDOM HTMLDOM FormsDOM CSSDOM AnimationsDOM EventsDOM Event ListenerDOM NavigationDOM NodesDOM CollectionsDOM Node Lists

JS Browser BOM

JS WindowJS ScreenJS LocationJS HistoryJS NavigatorJS Popup AlertJS TimingJS Cookies

JS Web APIs

Web API IntroWeb Forms APIWeb History APIWeb Storage APIWeb Worker APIWeb Fetch APIWeb Geolocation API

JS AJAX

AJAX IntroAJAX XMLHttpAJAX RequestAJAX ResponseAJAX XML FileAJAX PHPAJAX ASPAJAX DatabaseAJAX ApplicationsAJAX Examples

JS JSON

JSON IntroJSON SyntaxJSON vs XMLJSON Data TypesJSON ParseJSON StringifyJSON ObjectsJSON ArraysJSON ServerJSON PHPJSON HTMLJSON JSONP

JS vs jQuery

jQuery SelectorsjQuery HTMLjQuery CSSjQuery DOM

JS Graphics

JS GraphicsJS CanvasJS PlotlyJS Chart.jsJS Google ChartJS D3.js

JS Examples

JS ExamplesJS HTML DOMJS HTML InputJS HTML ObjectsJS HTML EventsJS BrowserJS EditorJS ExercisesJS QuizJS WebsiteJS SyllabusJS Study PlanJS Interview PrepJS BootcampJS Certificate

JS References

JavaScript ObjectsHTML DOM Objects


JavaScript HTML DOM


With the HTML DOM, JavaScript can access and change all the elements of an HTML document.


The HTML DOM (Document Object Model)

When a web page is loaded, the browser creates a Document Object Model of the page.

The HTML DOM model is constructed as a tree of Objects:

The HTML DOM Tree of Objects

DOM HTML tree

With the object model, JavaScript gets all the power it needs to create dynamic HTML:

  • JavaScript can change all the HTML elements in the page
  • JavaScript can change all the HTML attributes in the page
  • JavaScript can change all the CSS styles in the page
  • JavaScript can remove existing HTML elements and attributes
  • JavaScript can add new HTML elements and attributes
  • JavaScript can react to all existing HTML events in the page
  • JavaScript can create new HTML events in the page

What You Will Learn

In the next chapters of this tutorial you will learn:

  • How to change the content of HTML elements
  • How to change the style (CSS) of HTML elements
  • How to react to HTML DOM events
  • How to add and delete HTML elements


What is the DOM?

The DOM is a W3C (World Wide Web Consortium) standard.

The DOM defines a standard for accessing documents:

"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."

The W3C DOM standard is separated into 3 different parts:

  • Core DOM - standard model for all document types
  • XML DOM - standard model for XML documents
  • HTML DOM - standard model for HTML documents

What is the HTML DOM?

The HTML DOM is a standard object model and programming interface for HTML. It defines:

  • The HTML elements as objects
  • The properties of all HTML elements
  • The methods to access all HTML elements
  • The events for all HTML elements

In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML elements.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

close