aboutsummaryrefslogtreecommitdiff
path: root/_pastebins/2021-08-11-spaces-around-h1-tags.md
blob: 9a00ece9dfb3941e14a5ef3cf9a9d8825e0c64ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---

title: Spaces around h1 tags

date: 2021-08-11

updated_at: 2021-08-15

layout: post

lang: en

ref: spaces-around-h1-tags

---

*EDIT*: Apparently, the behaviour below is consistent between Firefox and
Chromium for links, but not for `<h1>`.
My conclusion is that the `<h1>` behaviour is a Firefox quirk, but the `<a>` is
expected.

---

The HTML below has selectable extra spaces after `<h1>` tags:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Spaces around h1 tags</title>
  </head>
  <body>
    <main>
      <h1>
        With spaces around when selecting this heading
      </h1>
      <h1>Without spaces around</h1>
      <p>
        Is this expected behaviour?
      </p>
    </main>
  </body>
</html>
```

The rendered output is:

<h1>
  With spaces around when selecting this heading
</h1>
<h1>Without spaces around</h1>
<p>
  Is this expected behaviour?
</p>

---

The same with links:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Spaces after a tags</title>
  </head>
  <body>
    <main>
      <p>
        <a href="#">
          With extra underlined space
        </a>
      </p>
      <p>
        <a href="#">Without extra underlined space</a>
      </p>
    </main>
  </body>
</html>
```

The rendered output is:

<p>
  <a href="#">
    With extra underlined space
  </a>
  after the link.
</p>
<p>
  <a href="#">Without extra underlined space</a>
  after the link.
</p>