DOM (extra) Flashcards
What is the Document Object Model (DOM)?
The DOM is a programming interface for HTML and XML documents. It represents a document as a tree of objects, allowing developers to create, read, update, and delete elements and content on a webpage.
What is XML?
XML, or Extensible Markup Language, is a markup language designed for storing and transporting data. Unlike HTML, which focuses on the display of data, XML’s primary purpose is to structure, store, and transport information in a way that is both human-readable and machine-readable.
Why is the DOM important in web development?
The DOM allows developers to:
- Change the content of a web page without reloading it.
- Create interactive and dynamic web applications.
- Manage the structure and style of documents separately.
What are the basic building blocks of the DOM?
The DOM consists of nodes and elements:
- Node: A single point in the DOM tree (like an HTML element, text, attribute, etc.).
- Element Node: Represents a specific HTML element, like < div>, < p>, or < img>
How is the DOM structured?
The DOM is structured as a tree, where:
- The root node is the < html> element.
- Each node can have child nodes (elements or text).
- Nodes are connected as parents, children, and siblings.
What are the main types of nodes in the DOM?
The main types of nodes are:
- Element Node: Represents HTML elements.
- Text Node: Contains the text inside an element.
- Attribute Node: Represents an attribute of an element (like class or id).
- Comment Node: Contains comments within the HTML or XML.
- Document Node: The root of the document, representing the entire HTML or XML document.
What are some common methods to access nodes in the DOM?
- getElementById(id): Returns the element with the specified ID.
- getElementsByTagName(tagName): Returns all elements with the specified tag name.
- getElementsByClassName(className): Returns all elements with the specified class name.
What is not included in the DOM specification?
The DOM does not define:
- How documents are represented in binary form.
- How data is stored or persisted.
- The semantics or meaning of HTML or XML elements.