Skip to content

Commit

Permalink
feat: selecting element
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Dec 3, 2024
1 parent 058e943 commit 64208c1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,42 @@ In DevTools, there is a **Console** tab, which gives access to ad-hoc experiment

## Selecting an element

In the top left corner of DevTools, find the icon with an arrow pointing to a square.

![Chrome DevTools element selection tool](./images/devtools-element-selection.png)

Hit the icon and hover your cursor over Wikipedia's subtitle, **The Free Encyclopedia**. As you move, DevTools will show you information about the HTML element under your cursor. Click on the subtitle. In the **Elements** tab, DevTools will highlight the HTML element which represents the subtitle.

![Chrome DevTools element hover](./images/devtools-hover.png)

The highlighted part should look something like this:

```html
<strong class="jsl10n localized-slogan" data-jsl10n="portal.slogan">
The Free Encyclopedia
</strong>
```

If we were experienced creators of scrapers, our eyes would immediately see what's needed if we wanted to have a program which fetches Wikipedia's subtitle. It would need to download the source code of the page, find a `strong` element with `localized-slogan` in its `class` attribute, and extract its text.

:::tip HTML and whitespace

In HTML, whitespace isn't significant, i.e. it only makes the code readable. The following code snippets represent the same:

```html
<strong>
The Free Encyclopedia
</strong>
```

```html
<strong>The Free
Encyclopedia
</strong>
```

:::

## Interacting with an element

:::danger Work in Progress
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 64208c1

Please sign in to comment.