Skip to content

Commit 3e20b7b

Browse files
authored
Language improvements
1 parent 2a3182a commit 3e20b7b

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

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

+25-25
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ libs:
66

77
# DOM tree
88

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

1111
According to Document Object Model (DOM), every HTML-tag is an object. Nested tags are called "children" of the enclosing one.
1212

@@ -44,7 +44,7 @@ drawHtmlTree(node1, 'div.domtree', 690, 320);
4444
On the picture above, you can click on element nodes and their children will open/collapse.
4545
```
4646

47-
Tags are called *element nodes* (or just elements). Nested tags become children of the enclosing ones. As a result we have a tree of elements: `<html>` is at the root, then `<head>` and `<body>` are its children etc.
47+
Tags are called *element nodes* (or just elements). Nested tags become children of the enclosing ones. As a result we have a tree of elements: `<html>` is at the root, then `<head>` and `<body>` are its children, etc.
4848

4949
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.
5050

@@ -55,15 +55,15 @@ Please note the special characters in text nodes:
5555
- a newline: `` (in JavaScript known as `\n`)
5656
- a space: ``
5757

58-
Spaces and newlines -- are totally valid characters, they form text nodes and become a part of the DOM. So, for instance, in the example above the `<head>` tag contains come spaces before `<title>`, and that text becomes a `#text` node (it contains a newline and some spaces only).
58+
Spaces and newlines -- are totally valid characters, 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).
5959

6060
There are only two top-level exclusions:
6161
1. Spaces and newlines before `<head>` are ignored for historical reasons,
62-
2. If we put something after `</body>`, then that is automatically moved inside the `body`, at the end, as HTML spec requires that all content must be inside `<body>`. So there may be no spaces after `</body>`.
62+
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>`.
6363

64-
In other cases everything's honest -- 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.
64+
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.
6565

66-
Here are no space-only text nodes:
66+
Here are no-space, text-only nodes:
6767

6868
```html no-beautify
6969
<!DOCTYPE HTML>
@@ -81,7 +81,7 @@ drawHtmlTree(node2, 'div.domtree', 690, 210);
8181
```smart header="Edge spaces and in-between empty text are usually hidden in tools"
8282
Browser tools (to be covered soon) that work with DOM usually do not show spaces at the start/end of the text and empty text nodes (line-breaks) between tags.
8383
84-
That's because they are mainly used to decorate HTML, and do not affect (in most cases) how it is shown.
84+
That's because they are mainly used to decorate HTML, and do not affect how it is shown (in most cases).
8585
8686
On further DOM pictures we'll sometimes omit them where they are irrelevant, to keep things short.
8787
```
@@ -91,7 +91,7 @@ On further DOM pictures we'll sometimes omit them where they are irrelevant, to
9191

9292
If the browser encounters malformed HTML, it automatically corrects it when making DOM.
9393

94-
For instance, the top tag is always `<html>`. Even if it doesn't exist in the document -- it will be in DOM, the browser will create it. The same about `<body>`.
94+
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>`.
9595

9696
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:
9797

@@ -104,7 +104,7 @@ let node3 = {"name":"HTML","nodeType":1,"children":[{"name":"HEAD","nodeType":1,
104104
drawHtmlTree(node3, 'div.domtree', 690, 150);
105105
</script>
106106

107-
While generating DOM, browser automatically processes errors in the document, closes tags and so on.
107+
While generating the DOM, browsers automatically process errors in the document, close tags and so on.
108108

109109
Such an "invalid" document:
110110

@@ -115,7 +115,7 @@ Such an "invalid" document:
115115
<li>Dad
116116
```
117117

118-
...Will become a normal DOM, as the browser read tags and restores the missing parts:
118+
...Will become a normal DOM, as the browser reads tags and restores the missing parts:
119119

120120
<div class="domtree"></div>
121121

@@ -143,7 +143,7 @@ let node5 = {"name":"TABLE","nodeType":1,"children":[{"name":"TBODY","nodeType":
143143
drawHtmlTree(node5, 'div.domtree', 600, 200);
144144
</script>
145145

146-
You see? The `<tbody>` has appeared out of nowhere. Should keep in mind while working with tables to avoid surprises.
146+
You see? The `<tbody>` appeared out of nowhere. You should keep this in mind while working with tables to avoid surprises.
147147
````
148148
149149
## Other node types
@@ -178,7 +178,7 @@ Here we see a new tree node type -- *comment node*, labeled as `#comment`.
178178
179179
We may think -- why a comment is added to the DOM? It doesn't affect the visual representation in any way. But there's a rule -- if something's in HTML, then it also must be in the DOM tree.
180180
181-
**Everything in HTML, even comments, becomes a part of DOM.**
181+
**Everything in HTML, even comments, becomes a part of the DOM.**
182182
183183
Even the `<!DOCTYPE...>` directive at the very beginning of HTML is also a DOM node. It's in the DOM tree right before `<html>`. We are not going to touch that node, we even don't draw it on diagrams for that reason, but it's there.
184184
@@ -189,39 +189,39 @@ There are [12 node types](https://dom.spec.whatwg.org/#node). In practice we usu
189189
1. `document` -- the "entry point" into DOM.
190190
2. element nodes -- HTML-tags, the tree building blocks.
191191
3. text nodes -- contain text.
192-
4. comments -- sometimes we can put the information there, it won't be shown, but JS can read it from DOM.
192+
4. comments -- sometimes we can put the information there, it won't be shown, but JS can read it from the DOM.
193193
194-
## See it yourself
194+
## See it for yourself
195195
196196
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.
197197
198198
## In the browser inspector
199199
200-
Another way to explore DOM is to use browser developer tools. Actually, that's what we use when developing.
200+
Another way to explore the DOM is to use the browser developer tools. Actually, that's what we use when developing.
201201
202-
To do so, open the web-page [elks.html](elks.html), turn on browser developer tools and switch to Elements tab.
202+
To do so, open the web-page [elks.html](elks.html), turn on the browser developer tools and switch to the Elements tab.
203203
204-
Should look like this:
204+
It should look like this:
205205
206206
![](elks.png)
207207
208208
You can see the DOM, click on elements, see their details and so on.
209209
210210
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.
211211
212-
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). Works great when we have a huge HTML page and would like to see the DOM of a particular place in it.
212+
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 particual element in it.
213213
214214
Another way to do it would be just right-clicking on a webpage and selecting "Inspect" in the context menu.
215215
216216
![](inspect.png)
217217
218-
At the right part of the tools there are following subtabs:
219-
- Styles -- we can see CSS applied to the current element rule by rule, including built-in rules (gray). Almost everything can be edited at-place including the dimensions/margins/paddings of the box below.
220-
- Computed -- to see CSS applied to the element by property: for each property we can see a rule that gives it (including CSS inheritance and such).
221-
- Event Listeners -- to see event listeners attached to DOM elements (we'll cover them in the next part of the tutorial).
218+
At the right part of the tools there are the following subtabs:
219+
- **Styles** -- we can see CSS applied to the current element rule by rule, including built-in rules (gray). Almost everything can be edited in-place, including the dimensions/margins/paddings of the box below.
220+
- **Computed** -- to see CSS applied to the element by property: for each property we can see a rule that gives it (including CSS inheritance and such).
221+
- **Event Listeners** -- to see event listeners attached to DOM elements (we'll cover them in the next part of the tutorial).
222222
- ...and so on.
223223
224-
The best way to study them is to click around. Most values are in-place editable.
224+
The best way to study them is to click around. Most values are editable in-place.
225225
226226
## Interaction with console
227227
@@ -244,7 +244,7 @@ Or we can just output it in the console and explore "at-place", like `document.b
244244
245245
That's for debugging purposes of course. From the next chapter on we'll access and modify DOM using JavaScript.
246246
247-
The browser developer tools are a great help in development: we can explore DOM, try things and see what goes wrong.
247+
The browser developer tools are a great help in development: we can explore the DOM, try things and see what goes wrong.
248248
249249
## Summary
250250
@@ -256,6 +256,6 @@ An HTML/XML document is represented inside the browser as the DOM tree.
256256
257257
We can use developer tools to inspect DOM and modify it manually.
258258
259-
Here we covered the basics, most used and important actions to start with. There's an extensive documentation about Chrome developer tools at <https://developers.google.com/web/tools/chrome-devtools>. The best way to learn the tools is to click here and there, read menus: most options are obvious. Later, when you know them in general, read the docs and pick up the rest.
259+
Here we covered the basics, the most used and important actions to start with. There's an extensive documentation about Chrome Developer Tools at <https://developers.google.com/web/tools/chrome-devtools>. The best way to learn the tools is to click here and there, read menus: most options are obvious. Later, when you know them in general, read the docs and pick up the rest.
260260
261261
DOM nodes have properties and methods that allow to travel between them, modify, move around the page and more. We'll get down to them in the next chapters.

0 commit comments

Comments
 (0)