Skip to content

Commit 8a3a247

Browse files
coliffCopilot
andauthored
docs: Add 'Why this rule is important' sections to rule docs (#1723)
* Add 'Why this rule is important' sections to rule docs Added explanations to multiple rule documentation files describing the importance of each rule for accessibility, SEO, and code quality. Also updated the configuration example to include the new 'form-method-require' rule and fixed changelog issue links. * Update website/src/content/docs/changelog.mdx Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 5e924e9 commit 8a3a247

14 files changed

+54
-5
lines changed

website/src/content/docs/changelog.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { Badge } from '@astrojs/starlight/components'
88
## 1.7.0 _(2025-09-11)_
99

1010
- <Badge text="Feat" size="small" /> New rule: [`form-method-require`](/rules/form-method-require/)
11-
[#1670](https://github.com/htmlhint/HTMLHint/issues/1670)
11+
[#1670](https://github.com/htmlhint/HTMLHint/issues/1721)
1212
- <Badge text="Feat" size="small" /> New rule: [`link-rel-canonical-require`](/rules/link-rel-canonical-require/)
13-
[#1671](https://github.com/htmlhint/HTMLHint/issues/1671)
13+
[#1671](https://github.com/htmlhint/HTMLHint/issues/1710)
1414

1515
## 1.6.3 _(2025-06-18)_
1616

website/src/content/docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ An example configuration file (with all rules disabled):
5555
"doctype-first": false,
5656
"doctype-html5": false,
5757
"empty-tag-not-self-closed": false,
58+
"form-method-require": false,
5859
"frame-title-require": false,
5960
"h1-require": false,
6061
"head-script-disabled": false,

website/src/content/docs/rules/alt-require.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ Level: <Badge text="Warning" variant="caution" />
3434
<input type="image" />
3535
<area shape="circle" coords="180,139,14" href="test.html" />
3636
```
37+
38+
### Why this rule is important
39+
40+
The alt attribute is used to provide alternative text for images, which helps improve accessibility for users who cannot see the image. It also helps with SEO by providing context for the image.

website/src/content/docs/rules/attr-lowercase.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ Level: <Badge text="Error" variant="danger" />
4040
```html
4141
<img SRC="test.png" ALT="test" />
4242
```
43+
44+
### Why this rule is important
45+
46+
Lowercase attribute names are required for HTML5 compliance and to ensure consistency across different HTML elements.

website/src/content/docs/rules/attr-no-duplication.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ Level: <Badge text="Error" variant="danger" />
2626
```html
2727
<img src="a.png" src="b.png" />
2828
```
29+
30+
### Why this rule is important
31+
32+
Duplicate attributes can cause unexpected behavior and make the code harder to read and maintain.

website/src/content/docs/rules/attr-whitespace.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ Level: <Badge text="Error" variant="danger" />
2828
<div title="a "></div>
2929
<div title=" a "></div>
3030
```
31+
32+
### Why this rule is important
33+
34+
Leading or trailing spaces inside attribute values can cause unexpected behavior and make the code harder to read and maintain.

website/src/content/docs/rules/doctype-first.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ Level: <Badge text="Error" variant="danger" />
3939
<!DOCTYPE html>
4040
<html></html>
4141
```
42+
43+
### Why this rule is important
44+
45+
The DOCTYPE declaration is required for HTML5 compliance and to ensure that the document is parsed correctly.

website/src/content/docs/rules/h1-require.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar:
88

99
import { Badge } from '@astrojs/starlight/components';
1010

11-
A H1 heading element is required in HTML documents. The heading can not be empty. This rule ensures that the document has a clear and accessible structure, which is important for both users and search engines.
11+
A H1 heading element is required in HTML documents. The heading can not be empty.
1212

1313
Level: <Badge text="Warning" variant="caution" />
1414

@@ -36,3 +36,7 @@ Level: <Badge text="Warning" variant="caution" />
3636
```html
3737
<html><body><h1> </h1></body></html>
3838
```
39+
40+
### Why this rule is important
41+
42+
The `<h1>` element is the main heading of the page and is used to provide a clear and concise title for the page. It is also used to help with SEO by providing a clear and concise title for the page.

website/src/content/docs/rules/html-lang-require.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ Level: <Badge text="Warning" variant="caution" />
3939
<!-- invalid BCP 47 lang value -->
4040
<html lang="-"></html>
4141
```
42+
43+
### Why this rule is important
44+
45+
The lang attribute is used to declare the language of the document, which helps with SEO and accessibility.

website/src/content/docs/rules/id-unique.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ Level: <Badge text="Error" variant="danger" />
2626
```html
2727
<div id="id1"></div><div id="id1"></div>
2828
```
29+
30+
### Why this rule is important
31+
32+
Duplicate ID attributes can cause unexpected behavior and make the code harder to read and maintain.

0 commit comments

Comments
 (0)