Skip to content

Commit e4ad3f5

Browse files
authored
Minor grammar fixes
Some capitalization, punctuation, articles
1 parent e9e4801 commit e4ad3f5

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

2-ui/1-document/02-dom-nodes/article.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ libs:
66

77
# DOM tree
88

9-
The backbone of an HTML document are tags.
9+
The backbone of an HTML document is tags.
1010

11-
According to Document Object Model (DOM), every HTML-tag is an object. Nested tags are "children" of the enclosing one. The text inside a tag it is an object as well.
11+
According to the Document Object Model (DOM), every HTML tag is an object. Nested tags are "children" of the enclosing one. The text inside a tag is an object as well.
1212

13-
All these objects are accessible using JavaScript, we can use them to modify the page.
13+
All these objects are accessible using JavaScript, and we can use them to modify the page.
1414

15-
For example, `document.body` is the object representing `<body>` tag.
15+
For example, `document.body` is the object representing the `<body>` tag.
1616

1717
Running this code will make the `<body>` red for 3 seconds:
1818

@@ -22,11 +22,11 @@ document.body.style.background = 'red'; // make the background red
2222
setTimeout(() => document.body.style.background = '', 3000); // return back
2323
```
2424

25-
That was just a glimpse of DOM power. Soon we'll learn more ways to manipulate DOM, but first we need to know about its structure.
25+
That was just a glimpse of the DOM's power. Soon we'll learn more ways to manipulate the DOM, but first we need to know about its structure.
2626

27-
## An example of DOM
27+
## An example of the DOM
2828

29-
Let's start with the following simple docment:
29+
Let's start with the following simple document:
3030

3131
```html run no-beautify
3232
<!DOCTYPE HTML>
@@ -56,7 +56,7 @@ On the picture above, you can click on element nodes and their children will ope
5656

5757
Every tree node is an object.
5858

59-
Tags are *element nodes* (or just elements), they form the tree structure: `<html>` is at the root, then `<head>` and `<body>` are its children, etc.
59+
Tags are *element nodes* (or just elements) and form the tree structure: `<html>` is at the root, then `<head>` and `<body>` are its children, etc.
6060

6161
The text inside elements forms *text nodes*, labelled as `#text`. A text node contains only a string. It may not have children and is always a leaf of the tree.
6262

@@ -67,13 +67,13 @@ Please note the special characters in text nodes:
6767
- a newline: `` (in JavaScript known as `\n`)
6868
- a space: ``
6969

70-
Spaces and newlines -- are totally valid characters, like letters and digits. They form text nodes and become a part of the DOM. So, for instance, in the example above the `<head>` tag contains some spaces before `<title>`, and that text becomes a `#text` node (it contains a newline and some spaces only).
70+
Spaces and newlines are totally valid characters, like letters and digits. They form text nodes and become a part of the DOM. So, for instance, in the example above the `<head>` tag contains some spaces before `<title>`, and that text becomes a `#text` node (it contains a newline and some spaces only).
7171

7272
There are only two top-level exclusions:
73-
1. Spaces and newlines before `<head>` are ignored for historical reasons,
74-
2. If we put something after `</body>`, then that is automatically moved inside the `body`, at the end, as the HTML spec requires that all content must be inside `<body>`. So there may be no spaces after `</body>`.
73+
1. Spaces and newlines before `<head>` are ignored for historical reasons.
74+
2. If we put something after `</body>`, then that is automatically moved inside the `body`, at the end, as the HTML spec requires that all content must be inside `<body>`. So there can't be any spaces after `</body>`.
7575

76-
In other cases everything's straightforward -- if there are spaces (just like any character) in the document, then they become text nodes in DOM, and if we remove them, then there won't be any.
76+
In other cases everything's straightforward -- if there are spaces (just like any character) in the document, then they become text nodes in the DOM, and if we remove them, then there won't be any.
7777

7878
Here are no space-only text nodes:
7979

@@ -100,11 +100,11 @@ On further DOM pictures we'll sometimes omit them when they are irrelevant. Such
100100

101101
## Autocorrection
102102

103-
If the browser encounters malformed HTML, it automatically corrects it when making DOM.
103+
If the browser encounters malformed HTML, it automatically corrects it when making the DOM.
104104

105-
For instance, the top tag is always `<html>`. Even if it doesn't exist in the document -- it will exist in the DOM, the browser will create it. The same goes for `<body>`.
105+
For instance, the top tag is always `<html>`. Even if it doesn't exist in the document, it will exist in the DOM, because the browser will create it. The same goes for `<body>`.
106106

107-
As an example, if the HTML file is a single word `"Hello"`, the browser will wrap it into `<html>` and `<body>`, add the required `<head>`, and the DOM will be:
107+
As an example, if the HTML file is the single word `"Hello"`, the browser will wrap it into `<html>` and `<body>`, and add the required `<head>`, and the DOM will be:
108108

109109

110110
<div class="domtree"></div>
@@ -117,7 +117,7 @@ drawHtmlTree(node3, 'div.domtree', 690, 150);
117117

118118
While generating the DOM, browsers automatically process errors in the document, close tags and so on.
119119

120-
Such document with unclosed tags:
120+
A document with unclosed tags:
121121

122122
```html no-beautify
123123
<p>Hello
@@ -126,7 +126,7 @@ Such document with unclosed tags:
126126
<li>Dad
127127
```
128128

129-
...Will become a normal DOM, as the browser reads tags and restores the missing parts:
129+
...will become a normal DOM as the browser reads tags and restores the missing parts:
130130

131131
<div class="domtree"></div>
132132

@@ -137,7 +137,7 @@ drawHtmlTree(node4, 'div.domtree', 690, 360);
137137
</script>
138138

139139
````warn header="Tables always have `<tbody>`"
140-
An interesting "special case" is tables. By the DOM specification they must have `<tbody>`, but HTML text may (officially) omit it. Then the browser creates `<tbody>` in DOM automatically.
140+
An interesting "special case" is tables. By the DOM specification they must have `<tbody>`, but HTML text may (officially) omit it. Then the browser creates `<tbody>` in the DOM automatically.
141141

142142
For the HTML:
143143

@@ -202,15 +202,15 @@ There are [12 node types](https://dom.spec.whatwg.org/#node). In practice we usu
202202
1. `document` -- the "entry point" into DOM.
203203
2. element nodes -- HTML-tags, the tree building blocks.
204204
3. text nodes -- contain text.
205-
4. comments -- sometimes we can put the information there, it won't be shown, but JS can read it from the DOM.
205+
4. comments -- sometimes we can put information there, it won't be shown, but JS can read it from the DOM.
206206
207207
## See it for yourself
208208
209-
To see the DOM structure in real-time, try [Live DOM Viewer](http://software.hixie.ch/utilities/js/live-dom-viewer/). Just type in the document, and it will show up DOM at an instant.
209+
To see the DOM structure in real-time, try [Live DOM Viewer](http://software.hixie.ch/utilities/js/live-dom-viewer/). Just type in the document, and it will show up as a DOM at an instant.
210210
211211
Another way to explore the DOM is to use the browser developer tools. Actually, that's what we use when developing.
212212
213-
To do so, open the web-page [elks.html](elks.html), turn on the browser developer tools and switch to the Elements tab.
213+
To do so, open the web page [elks.html](elks.html), turn on the browser developer tools and switch to the Elements tab.
214214
215215
It should look like this:
216216
@@ -220,7 +220,7 @@ You can see the DOM, click on elements, see their details and so on.
220220
221221
Please note that the DOM structure in developer tools is simplified. Text nodes are shown just as text. And there are no "blank" (space only) text nodes at all. That's fine, because most of the time we are interested in element nodes.
222222
223-
Clicking the <span class="devtools" style="background-position:-328px -124px"></span> button in the left-upper corner allows to choose a node from the webpage using a mouse (or other pointer devices) and "inspect" it (scroll to it in the Elements tab). This works great when we have a huge HTML page (and corresponding huge DOM) and would like to see the place of a particular element in it.
223+
Clicking the <span class="devtools" style="background-position:-328px -124px"></span> button in the left-upper corner allows us to choose a node from the webpage using a mouse (or other pointer devices) and "inspect" it (scroll to it in the Elements tab). This works great when we have a huge HTML page (and corresponding huge DOM) and would like to see the place of a particular element in it.
224224
225225
Another way to do it would be just right-clicking on a webpage and selecting "Inspect" in the context menu.
226226
@@ -253,7 +253,7 @@ That's how to get a node from Elements in Console.
253253
254254
There's also a road back. If there's a variable referencing a DOM node, then we can use the command `inspect(node)` in Console to see it in the Elements pane.
255255
256-
Or we can just output DOM-node in the console and explore "at-place", like `document.body` below:
256+
Or we can just output the DOM node in the console and explore "in-place", like `document.body` below:
257257
258258
![](domconsole1.png)
259259

0 commit comments

Comments
 (0)