Skip to content

HTML Hint showcase #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .htmlhintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tag-pair": true,
"attr-value-double-quotes": true,
"doctype-first": true,
"id-unique": true
}


16 changes: 16 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<title>Bad Page<title>
</head>
<body>
<h1>Welcome
<img src="image.jpg">
<p>This paragraph is missing its closing tag
<a href="about.html">About us
<ul>
<li>Item 1
<li>Item 2
</ul
</body>
</html>
Comment on lines +1 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Document lacks DOCTYPE and several closing tags – HTMLHint will flag this.

Right now the first fragment violates every rule you just enabled:

  • No <!DOCTYPE html> before <html>doctype-first.
  • Unclosed <title>, <h1>, <p>, <a>, <li> tags → tag-pair.
  • Malformed </ul (missing >) → parsing error.

Unless the goal is to demonstrate failing cases, consider fixing them so the file passes lint:

+<!DOCTYPE html>
 <html>
   <head>
-    <title>Bad Page<title>
+    <title>Bad Page</title>
   </head>
   <body>
-    <h1>Welcome
-    <img src="image.jpg">
-    <p>This paragraph is missing its closing tag
-    <a href="about.html">About us
-    <ul>
-      <li>Item 1
-      <li>Item 2
-    </ul
+    <h1>Welcome</h1>
+    <img src="image.jpg" alt="Sample image">
+    <p>This paragraph is now properly closed.</p>
+    <a href="about.html">About us</a>
+    <ul>
+      <li>Item 1</li>
+      <li>Item 2</li>
+    </ul>
   </body>
 </html>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<html>
<head>
<title>Bad Page<title>
</head>
<body>
<h1>Welcome
<img src="image.jpg">
<p>This paragraph is missing its closing tag
<a href="about.html">About us
<ul>
<li>Item 1
<li>Item 2
</ul
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Bad Page</title>
</head>
<body>
<h1>Welcome</h1>
<img src="image.jpg" alt="Sample image">
<p>This paragraph is now properly closed.</p>
<a href="about.html">About us</a>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</body>
</html>
🧰 Tools
🪛 HTMLHint (1.5.0)

[error] 1-1: Doctype must be declared before any non-comment content.

(doctype-first)


[error] 3-3: Tag must be paired, missing: [ </title></title> ], start tag match failed [ <title> ] on line 3.

(tag-pair)


[error] 12-12: Tag must be paired, missing: [

], start tag match failed [
  • ] on line 12.

    (tag-pair)

  • 🤖 Prompt for AI Agents
    In test.html lines 1 to 15, the document is missing the <!DOCTYPE html>
    declaration at the top, and several tags such as <title>, <h1>, <p>, <a>, and
    <li> are not properly closed. Additionally, the closing </ul> tag is malformed
    and missing the closing angle bracket. To fix this, add <!DOCTYPE html> before
    the <html> tag, properly close all opened tags with their corresponding closing
    tags, and correct the </ul> tag by adding the missing '>'. This will ensure the
    HTML is well-formed and passes lint checks.
    

    <html><body><h1>Oops<img src="a.png"></body></html>
    Copy link

    @coderabbitai coderabbitai bot Jul 14, 2025

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    🛠️ Refactor suggestion

    Two complete HTML documents in one file – split or comment out.

    Line 16 embeds a second <html> element directly after the first document’s closing tag. Browsers treat everything after the first root element unpredictably, and HTMLHint will report duplicate-ID issues if any appear. If you need both snippets, place each in its own file (e.g., test-bad.html and test-good.html) or wrap the second inside a comment.

    🧰 Tools
    🪛 HTMLHint (1.5.0)

    [error] 16-16: Tag must be paired, missing: [ </h1> ], start tag match failed [ <h1> ] on line 16.

    (tag-pair)

    🤖 Prompt for AI Agents
    In test.html at line 16, there is a second <html> element embedded directly
    after the first document's closing tag, causing invalid HTML structure. To fix
    this, either split the content into two separate HTML files or comment out the
    second <html> element and its contents to avoid duplicate root elements and
    potential duplicate-ID issues.