Learn Practice Daily golf Reference
Text objects·Lesson 5 of 8·7 min·0/8 exercisesPro

Tags

Tags are the labels on each end of the foil: it is the text between them, at the element with both tags, and 2it reaches the next element out.

Scene

Tuesday, 3:10 p.m. The website reads the new menu.json, but the template doesn't yet: every item on the page says TODO where its name should be. menu.html is angle brackets from top to bottom.

The names sit between an opening tag and a closing tag, which is a wrapping of its own.

From memory

Warm-up from earlier chapters

Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.

Delete these brackets and everything in them.
press the keys…3 keys
1 of 2
Delete these brackets and everything in them.

Labels on the foil

Think of the tags as labels printed on each end of the foil: <span class="name"> at one end, </span> at the other. it is the filling between the two labels, and at is the whole element, both labels included. From anywhere in the element (even on the class in its opening tag), cit replaces the text.

it
<li class="item"><span class="name">Al Pastor</span> <b>$9.50</b></li>
at
<li class="item"><span class="name">Al Pastor</span> <b>$9.50</b></li>
2it
<li class="item"><span class="name">Al Pastor</span> <b>$9.50</b></li>
From the middle of the name: the filling, the element with its labels, and (a count again) the filling of the next element out.
1<li class="item"><span class="name">TODO</span> <b>$9.50</b></li>
NORMALLoading the editor…1:39
Try it

Names on the page

Three TODOs where the names belong. cit from anywhere in each <span>, and type the name.

1 of 3Change the red text to Al Pastor
1<section class="menu">
1 <h2>Today's menu</h2>
2 <ul>
3 <li class="item"><span class="name">TODO</span> <b>$9.50</b></li>
4 <li class="item"><span class="name">TODO</span> <b>$10</b></li>
5 <li class="item"><span class="name">TODO</span> <b>$8.25</b></li>
6 </ul>
7 <p class="note">Spicy items are marked in red.</p>
8</section>
NORMALLoading the editor…1/30.0s1:1

This exercise needs a keyboard. Read on, and play it at your computer.

Labels, and nothing else

aw and a" take a space with them; at doesn't. The element's foil is its two labels and nothing more, so deleting an element in the middle of a sentence leaves the spaces from both sides behind.

Check yourself

What does at leave?

1<p>Spicy <em>items</em> are red.</p>
NORMAL
Keys pressed: dat

The cursor is in items. You press dat. What is left?

Pick an answer (or press its number), then watch the engine prove it.
Try it

Lost text

Text between tags lost across the HTML files. cit and type it back.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Try it

Labels, fillings, whole items

Three changes from the kitchen. Al Pastor gets a second class: its <li> becomes class="item spicy" (that value sits in quotes, not between tags). Carnitas now costs $10.50. And Garden Veggie is sold out: everything inside its <li>, name and price, becomes Sold out today.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

From memory

Tags, from memory

Press the keys. The cursor is inside the element.

Change the text between these tags.
scroll here, then press the keys3 keys
1 of 4
Change the text between these tags.
Challenge

Template sweep

Ten lost texts and wrong attributes across the HTML files. Tags and quotes.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Boss round

The menu template

3:40. The template, top to bottom: the heading is still placeholder text, Carnitas costs $100 instead of $10, Garden Veggie is a TODO, and the note's emphasis should say just red. Four fillings, four pairs of labels.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

menu.html, in a browserFinish the exercise above to see it.

Extra practice optional

The chapter is done. These rounds keep going as long as you like: stop whenever it stops being useful.

Endless

Tags, endlessly

Endless lost texts and attributes in the HTML files.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.