> For the complete documentation index, see [llms.txt](https://aleksandra-hrevtsova.gitbook.io/senior-front-end-javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aleksandra-hrevtsova.gitbook.io/senior-front-end-javascript/dom.md).

# DOM

Разметка HTML имеет вложенную структуру.

Тег html заключает в себе head со всеми настройками и подключаемыми файлами и body с вложенной в него разметкой страницы.&#x20;

Тег body в свою очередь имеет вложенные теги с разметкой, согласно семантике и так далее.

```
<!DOCTYPE html>
<html>
  <head>
    <title>Document title</title>
  </head>
  <body>
    <h1>Page title</h1>
    <ul>
      <li><a href="#">Link 1</a></li>
      <li><a href="#">Link 2</a></li>
    </ul>
  </body>
</html>
```

Первое, что считывает браузер при загрузке страницы - это код HTML.&#x20;

После полной загрузки HTML формируется DOM - объектная модель документа.

DOM cостоит из узлов. Их три вида:

1. Element node - узел-элемент.
2. Text node - текстовый узел.
3. Comment node - узел-комментарий.

Все логично, ведь в коде HTML у нас есть теги - они соответствуют узлам-элементам, текст внутри тегов, пробелы и переносы строк, соответственно текстовые узлы, ну узлами-комментариями становятся непосредственно комментарии.

![Представление разметки в виде DOM-узлов](/files/oGP7cGqOgToGOzLVu4yF)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aleksandra-hrevtsova.gitbook.io/senior-front-end-javascript/dom.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
