DOM tree

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

If the browser encounters malformed HTML, how is it represented in the DOM?

All elements are wrapped inside HTML and body elements. Head element is also added. Unclosed tags are still processed correctly. For tables, a tbody tag is added to the DOM as the child of the table if it is omitted in the HTML.

Spaces and newlines form what nodes?

text nodes

What nodes are always leaf nodes?

text nodes

What type of nodes is text represented as in the DOM?

text nodes

What are the four node types that are commonly used in practice?

1. document nodes 2. element nodes 3. text nodes 4. comment nodes

How many node types are there in the DOM specification?

12 types but only 4 are used in practice.

What is the "special case" of auto correction for tables?

By the DOM specification they must have a tbody tag as the child of the table, but HTML text may (officially) omit it. Then the browser creates tbody in the DOM automatically. Every other table child node (e.g., tr, td, text) becomes a child of this tbody element node.

What does the innerHTML property do?

Changes the HTML contents of a node.

What does the style.background property do?

Changes the background color of a node.

What does the offsetWidth property do?

Changes the node width (in pixels).

Are comments represented as nodes in the DOM?

Yes, they are represented as comment nodes.

Can text nodes be displayed before the head node?

No, they are ignored for historical reasons.

According to the Document Object Model (DOM), what data type are HTML tags and text inside HTML tags?

Objects

How are spaces and newlines before/after text strings represented in the DOM?

Spaces at string start/end and space-only text nodes are usually hidden.

If something appears in the HTML document, it must also appear where?

The DOM

Which structure does the DOM use to represent an HTML document?

The DOM represents HTML as a tree structure of tags.

What happens to nodes placed after the body node?

They are automatically moved inside the body node. HTML spec requires that all content must be inside body.

What is the "entry point" of the DOM?

document node

Which object represents the body tag?

document.body

What type of nodes are tags represented as in the DOM?

element nodes


Ensembles d'études connexes

Quiz 5: Conceptualization, Operationalization, and Measurement

View Set

Because God Is Real - Chapter 16

View Set

A&P Chapter 2: four major organic molecules

View Set

Quiz 6 - Entry and Exit Decision

View Set

BUS171 Chapter 2: Analyzing the Business Case

View Set

Chapter 2: Principles of Physical Fitness

View Set