> For the complete documentation index, see [llms.txt](https://simon-6.gitbook.io/simoncyber/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simon-6.gitbook.io/simoncyber/portswigger-web-academy/xss/dom-based-xss/lab-3.md).

# Lab 3

<figure><img src="/files/WdZDkHBombjQakg0lwHQ" alt=""><figcaption></figcaption></figure>

#### The setup

Every HTML element has these properties. Say you have this on a page:

```html
<div id="box" class="wrapper">
  <p>Hello <b>world</b></p>
</div>

var el = document.getElementById('box');
```

`el.innerHTML` gives you (or sets) the HTML **inside** the element, not including the element itself.

```
el.innerHTML
// returns: "<p>Hello <b>world</b></p>"
```

#### `outerHTML` — the element itself, contents *and* tags

`el.outerHTML` gives you (or sets) the HTML **of the element itself, including its opening and closing tags**.

**Reading:**

```javascript
el.outerHTML
// returns: '<div id="box" class="wrapper"><p>Hello <b>world</b></p></div>'
```

<figure><img src="/files/yOZ7UZj7FXFHI86a8yBx" alt=""><figcaption></figcaption></figure>

The `href` attribute is special. When a user clicks a link, the browser tries to navigate to whatever's in `href`. It supports several URL schemes:

* `http://...` → normal web request
* `https://...` → secure web request
* `mailto:...` → open email client
* `tel:...` → dial phone number
* `ftp://...` → FTP protocol
* **`javascript:...` → execute the rest as JavaScript**

When you look at:

```html
<a href="/login" class="btn" onclick="doThing()">Sign in</a>
```

You should see: "anchor tag, three attributes (href, class, onclick), content is 'Sign in'." This should be as automatic as reading English.

* Tags, Attributes, Content

**The complete list of void elements in HTML5:**

| Element    | What it does                                  |
| ---------- | --------------------------------------------- |
| `<area>`   | Clickable area in an image map                |
| `<base>`   | Base URL for all relative URLs on the page    |
| `<br>`     | Line break                                    |
| `<col>`    | Column in a table                             |
| `<embed>`  | Embedded content (like Flash back in the day) |
| `<hr>`     | Horizontal rule (a line divider)              |
| `<img>`    | Image                                         |
| `<input>`  | Form input                                    |
| `<link>`   | External resource link (usually CSS)          |
| `<meta>`   | Metadata about the document                   |
| `<source>` | Media source for `<video>` or `<audio>`       |
| `<track>`  | Text track for `<video>` or `<audio>`         |
| `<wbr>`    | Word break opportunity                        |

These are void tags and they do not contain any content, hence they don't need a closing tag, and they can be enclosed in just one big tag.&#x20;

**Characteristics:**

* Void elements do not have end tags.
* Void elements cannot have content inside it.
* Void elements have attributes.
* Void elements cannot be nested.
