📦 Out of the box and into your content operations: explore the Spring Release →
Skip to content
  • Docs
  • Enterprise
  • Pricing
Log inContact SalesGet started

  • Content operations

    • Sanity StudioThe TypeScript CMS
    • Media LibraryCentralized asset management
    • CanvasAI-assisted, free-form writing
    • ReleasesStack and stage content updates
    • InsightsUnderstand content performance
    • App SDKRapidly build content apps

    Content backend

    • Content LakeThe content optimized database
    • Live CDNSimple, scalable, real-time
    • ComputeEvent handlers for content changes
    • Agent ActionsBuilt-in, content aware AI
  • Use Cases

    • Unified content OS
    • Marketing
    • E-commerce
    • Media and publishing
    • PIM
    • LMS
    • Build your own

    Users

    • Developers
    • Content Editors
    • Product Owners
    • Business Leaders
  • Build and Share

    • Sanity Learn
    • Integrations
    • Frameworks
    • Templates
    • Tools and Plugins
    • Schemas and snippets
    • Join our community

    Insight

    • Blog
    • Events
    • Customer stories
    • Guides
  • Docs
  • Enterprise
  • Pricing
Get startedContact Sales

Page content

  • What is the Document Object Model?
  • How does the Document Object Model work?
  • Why is the Document Object Model important?
  • Examples of using the Document Object Model
  • All glossary terms

      • API gateway
      • API-First
      • Accessibility
      • Angular
      • Astro
      • Asynchronous loading
      • Atomic design

      • Backend as a Service

      • Cache invalidation
      • Client Side Rendering (CSR)
      • Component library
      • Composability
      • Content Delivery Network (CDN)
      • Content archiving
      • Content auditing
      • Content block
      • Content lifecycle
      • Content workflow automation
      • Continuous delivery (CD)
      • Cross-Site Scripting
      • Custom input component
      • Customer Data Platform (CDP)

      • Dark mode
      • Deployment
      • DevOps
      • Digital Asset Management
      • Document Object Model

      • Edge computing
      • Edge content delivery
      • Edge function
      • Editing environment
      • Eleventy (11ty)
      • End-to-end encryption
      • Extensibility

      • Feature flags
      • Feature rollout
      • Feature testing
      • Flutter
      • Front end

      • Gatsby
      • GraphQL

      • Hot Module Replacement (HMR)
      • Hugo
      • Hybrid rendering

      • Image Optimization
      • Incremental Static Regeneration (ISR)
      • Infrastructure as Code
      • Internet of Things
      • Islands architecture
      • Isomorphic JavaScript

      • JSON Web Token
      • JSON document
      • JSX
      • Jamstack
      • JavaScript framework

      • Knowledge graph
      • Kubernetes

      • Lazy loading

      • Markdown
      • Microfrontend
      • Microservices
      • Mobile Deep Linking
      • Mobile-first design
      • Modular content
      • Multi-Page Application
      • Multi-tenancy

      • Next.js
      • NoSQL
      • Node.js
      • Nuxt

      • OAuth

      • Partial hydration
      • Partial prerendering
      • Personalization engine
      • Preact
      • Product Information Management
      • Progressive Web Application (PWA)

      • Query Language

      • RESTful API
      • React Native
      • React Server Components
      • React.js
      • Release cycle
      • Remix
      • Rendering
      • Repurposing content
      • Retrieval Augmented Generation
      • Reusable content
      • Rich Text
      • Role-Based Access Control

      • SAML
      • Scalable Vector Graphic (SVG)
      • Schema Markup
      • Server Side Rendering (SSR)
      • Serverless function
      • Single Page Application (SPA)
      • Single Sign-On (SSO)
      • Static Site Generation
      • Svelte
      • SvelteKit

      • Two-factor authentication

      • UX prototyping
      • User flow

      • Version control
      • Vibe coding
      • Virtual DOM
      • Vite
      • Vue.js

      • Webhook

      • YAML
    Back to glossary

    Document Object Model definition

    The Document Object Model (DOM) is a programming interface that allows scripts to interact with and manipulate web documents.

    Page content

    • What is the Document Object Model?
    • How does the Document Object Model work?
    • Why is the Document Object Model important?
    • Examples of using the Document Object Model
  • All glossary terms

      • API gateway
      • API-First
      • Accessibility
      • Angular
      • Astro
      • Asynchronous loading
      • Atomic design

      • Backend as a Service

      • Cache invalidation
      • Client Side Rendering (CSR)
      • Component library
      • Composability
      • Content Delivery Network (CDN)
      • Content archiving
      • Content auditing
      • Content block
      • Content lifecycle
      • Content workflow automation
      • Continuous delivery (CD)
      • Cross-Site Scripting
      • Custom input component
      • Customer Data Platform (CDP)

      • Dark mode
      • Deployment
      • DevOps
      • Digital Asset Management
      • Document Object Model

      • Edge computing
      • Edge content delivery
      • Edge function
      • Editing environment
      • Eleventy (11ty)
      • End-to-end encryption
      • Extensibility

      • Feature flags
      • Feature rollout
      • Feature testing
      • Flutter
      • Front end

      • Gatsby
      • GraphQL

      • Hot Module Replacement (HMR)
      • Hugo
      • Hybrid rendering

      • Image Optimization
      • Incremental Static Regeneration (ISR)
      • Infrastructure as Code
      • Internet of Things
      • Islands architecture
      • Isomorphic JavaScript

      • JSON Web Token
      • JSON document
      • JSX
      • Jamstack
      • JavaScript framework

      • Knowledge graph
      • Kubernetes

      • Lazy loading

      • Markdown
      • Microfrontend
      • Microservices
      • Mobile Deep Linking
      • Mobile-first design
      • Modular content
      • Multi-Page Application
      • Multi-tenancy

      • Next.js
      • NoSQL
      • Node.js
      • Nuxt

      • OAuth

      • Partial hydration
      • Partial prerendering
      • Personalization engine
      • Preact
      • Product Information Management
      • Progressive Web Application (PWA)

      • Query Language

      • RESTful API
      • React Native
      • React Server Components
      • React.js
      • Release cycle
      • Remix
      • Rendering
      • Repurposing content
      • Retrieval Augmented Generation
      • Reusable content
      • Rich Text
      • Role-Based Access Control

      • SAML
      • Scalable Vector Graphic (SVG)
      • Schema Markup
      • Server Side Rendering (SSR)
      • Serverless function
      • Single Page Application (SPA)
      • Single Sign-On (SSO)
      • Static Site Generation
      • Svelte
      • SvelteKit

      • Two-factor authentication

      • UX prototyping
      • User flow

      • Version control
      • Vibe coding
      • Virtual DOM
      • Vite
      • Vue.js

      • Webhook

      • YAML

    What is the Document Object Model?

    The Document Object Model, often referred to as the DOM, is a critical component of web technology. It presents a structured, tree-like representation of a web document, where every element of the webpage, such as images, paragraphs, and headers, is represented as an object or a 'node'. This structure allows scripts, typically written in JavaScript, to interact with and manipulate the content, structure, and style of the webpage in a dynamic and interactive manner.

    The DOM is not a programming language itself but an interface that bridges the gap between static HTML documents and dynamic scripting languages like JavaScript. It's like a canvas that allows developers to paint interactive features onto a static webpage.

    One of the key aspects of the DOM is its language independence. While it's most commonly accessed and manipulated using JavaScript, it can be implemented in various languages. This flexible nature makes it a universal tool for web development.

    How does the Document Object Model work?

    The Document Object Model works by representing a webpage as a tree-like structure, known as the DOM tree. Each element on the webpage, such as a paragraph or an image, is represented as a node in this tree. This hierarchical representation allows scripts to easily navigate and manipulate the webpage.

    When a webpage is loaded, the browser creates the DOM of that page, which is an object-oriented representation of the HTML elements present on the page. Each node in the DOM tree corresponds to an object which has properties and methods. Properties are characteristics of the HTML elements such as their name or value, while methods are actions that can be performed on these elements.

    Scripts, often written in JavaScript, interact with the DOM to change the content, structure, or style of the webpage. They do this by accessing and manipulating the properties and methods of the objects in the DOM tree.

    Why is the Document Object Model important?

    The Document Object Model is essential for creating interactive and dynamic web experiences. It's the backbone of modern web development, enabling scripts to dynamically access and modify the content, structure, and style of a webpage. Without the DOM, webpages would be static, limiting user engagement and interactivity.

    In addition to enabling interactivity, the DOM also facilitates efficient updates and modifications to web content. Changes made through the DOM are instantly reflected on the webpage without requiring a complete page reload. This leads to a smoother and more responsive user experience.

    From a developer's perspective, the DOM's language-independent nature is a significant advantage. It allows for flexibility in choosing programming languages, making it a versatile tool in a developer's toolkit.

    Examples of using the Document Object Model

    The Document Object Model is a powerful tool that enables developers to create dynamic and interactive web experiences. Let's explore some examples of how the DOM is used in practice.

    One common use of the DOM is to access HTML elements on a webpage. For instance, developers can use JavaScript and the DOM to select a specific paragraph element and change its text content. This is done by first accessing the element using a method like getElementById(), and then modifying its textContent property.

    Another example is adding new elements to a webpage. Developers can create a new element, set its properties, and then append it to an existing element on the webpage. This allows for dynamic content creation on the fly, without needing to reload the entire page.

    Event handling is another crucial application of the DOM. Developers can attach event listeners to HTML elements that trigger functions when certain events occur, like a button click or a mouse hover. This makes webpages interactive and responsive to user actions.

    In Sanity's context, these DOM manipulations are fundamental for creating customized content experiences. By treating content as data and leveraging the DOM, Sanity allows developers to dynamically alter web content, making it possible to create personalized user experiences on any platform or device.

    Ready to explore Sanity?

    Find out how you can create dynamic, personalized content experiences.

    Watch demo nowGet started

    Last updated: August 23, 2024

    Join our community
    Subscribe to our newsletter

    Products

    • Sanity Studio
    • Content Lake
    • APIs
    • Canvas
    • AI Assist
    • Changelog
    • Use cases

    Resources

    • Docs
    • Learn
    • Templates
    • Resource Library
    • Guides
    • Explainers
    • Compare Sanity
    • Glossary

    Company

    • Blog
    • Events
    • Customer Stories
    • Careers
    • Agency Partners
    • Technology Partners

    Trust and compliance

    • Privacy policy
    • Terms of service
    • Accessibility statement
    • Transparency statement
    • Security and compliance
    • Open Source pledge

    Keep in touch

    © SANITY 2025

    OSL, NOR (CET)

    SFO, USA (PST)

    Loading system status...