M2- HTML documents Flashcards

Module 2

1
Q

What would a webpage look like if it was just an HTML document?

A

If a webpage was just an HTML document, users could only perform basic actions like scrolling the page, viewing pictures, and reading text. However, they wouldn’t be able to interact with the page by logging in, liking posts, or receiving notifications for new messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why are these interactive features not possible with just HTML?

A

HTML alone is static and doesn’t allow for user interaction with objects on the page. To enable such interactions, we need JavaScript to modify the page dynamically, which involves working with objects like reaction icons or comment buttons.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Document Object Model (DOM)?

A

The Document Object Model (DOM) is a programming interface for web documents. It represents the webpage as a structured tree or model of objects, allowing JavaScript to query, update, and interact with the HTML elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is the purpose of DOM?

A

The main goal of the DOM is to provide a standard way to access and manipulate the structure and content of documents, regardless of the programming language or the environment in which the document is being used. This standardization allows for interoperability between different systems and applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is DOM Important?

A
  • The DOM allows you to change or update parts of a web page without refreshing the entire page.
  • It’s the foundation for making web pages interactive and dynamic.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does a web browser create the DOM?

A

When a web browser receives an HTML page, it parses the HTML content and constructs a corresponding DOM to represent it as a structured, hierarchical tree of nodes.

parse: to split file or input into pieces of data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the key components of the DOM?

A

The key components of the DOM include:

1) HTML Elements: These are the building blocks of a webpage, such as headings, paragraphs, images, buttons, and forms. Each HTML element is represented as an object in the DOM.

2) DOM Tree: The DOM represents the HTML document as a tree-like structure. At the top of the tree is the root element, which is usually the < html> tag.

3) Nodes: Each element in the DOM tree is called a node, which can be an element node, text node, attribute node, or comment node.

4) Parent and Child Nodes: Nodes in the DOM tree have relationships with other nodes. A parent node is the node that contains other nodes, while child nodes are the nodes contained within a parent node. For example, a < div> element can be a parent node that contains other elements as its child nodes.

5) Properties and Methods: Each node in the DOM has properties and methods that can be accessed and manipulated using JavaScript. Properties allow you to get or set information about a node, such as its content or attributes. Methods enable you to perform actions on nodes, such as adding or removing elements from the DOM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can you provide an example of a simple HTML page and its corresponding DOM structure?

A

HTML page:
< html>
< head>
< title>Page Title< /title>
< /head>
< body>
< div>
< h1>Welcome< /h1>
< /div>
< div>
< p>Hello, World!< /p>
< /div>
< /body>
</ html>
DOM Structure:
* html (root node)

  • head
    * title (contains text “Page Title”)
  • body
    * div (first div)
    • h1 (contains text “Welcome”)
      * div (second div)
    • p (contains text “Hello, World!”)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can developers use JavaScript to interact with the DOM?

A

Developers can use JavaScript to access and modify the elements in the DOM. This can be done through various methods and properties provided by the DOM API.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can JavaScript handle user actions on a webpage?

A

JavaScript can handle user actions through events. Events are actions that occur as a result of the user interacting with the webpage, such as clicking a button or hovering over an element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is dynamic content, and how is it implemented using the DOM?

A

Dynamic content refers to content that can change without requiring the entire page to reload. This is implemented by modifying the DOM using JavaScript to update or replace content in response to user actions or other conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do libraries and frameworks like React utilize the DOM?

A

Libraries and frameworks like React use the DOM to create and manage the user interface. React, for example, utilizes a virtual DOM to improve performance by reducing the number of direct manipulations to the actual DOM, making it more efficient to update and render elements on the page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly