From 9504dac66c40ab5e2eeb5635b804cbe8ae66807d Mon Sep 17 00:00:00 2001 From: Tony Ruscoe Date: Wed, 6 Nov 2024 10:53:39 +0000 Subject: [PATCH] Update the HTML Document Type guidance (#862) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update explicitly declares quirks mode to be against the style guide and strengthens the recommendation from “preferred” to “mandatory”. It also updates examples to use lowercase for consistency and clarifies that the style guide applies to Sass. --- htmlcssguide.html | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/htmlcssguide.html b/htmlcssguide.html index 1a4b21c..185822a 100644 --- a/htmlcssguide.html +++ b/htmlcssguide.html @@ -15,9 +15,9 @@

This document defines formatting and style rules for HTML and CSS. It aims at improving collaboration, code quality, and enabling supporting infrastructure. -It applies to raw, working files that use HTML and CSS, including GSS files. -Tools are free to obfuscate, minify, and compile as long as the general code -quality is maintained.

+It applies to raw, working files that use HTML and CSS, including Sass and GSS +files. Tools are free to obfuscate, minify, and compile as long as the general +code quality is maintained.

General

@@ -165,13 +165,17 @@ depends on the project’s complexity.)

Document Type

-

Use HTML5.

+

Use <!doctype html>.

-

HTML5 (HTML syntax) is preferred for all HTML documents: <!DOCTYPE html>.

+

Always put your HTML in +no-quirks mode +by including <!doctype html> at the beginning of the document.

-

(It’s recommended to use HTML, as text/html. Do not use XHTML. XHTML, as -application/xhtml+xml, lacks both browser -and infrastructure support and offers less room for optimization than HTML.)

+

A document without a doctype is rendered in “quirks mode”, and one with a +different doctype may be rendered in “limited-quirks mode”. These modes don’t +follow the widely-understood, widely-documented behavior for various core HTML +and CSS constructs, and are likely to cause subtle failures and +incompatibilities especially when re-using code that expects no-quirks mode.

HTML Validity

@@ -194,7 +198,7 @@ HTML usage.

<!-- Recommended -->
-<!DOCTYPE html>
+<!doctype html>
 <meta charset="utf-8">
 <title>Test</title>
 <article>This is only a test.</article>
@@ -263,7 +267,7 @@ maintenance reasons. It is always more expensive to change HTML documents and
 templates than it is to update style sheets and scripts.

<!-- Not recommended -->
-<!DOCTYPE html>
+<!doctype html>
 <title>HTML sucks</title>
 <link rel="stylesheet" href="base.css" media="screen">
 <link rel="stylesheet" href="grid.css" media="screen">
@@ -276,7 +280,7 @@ templates than it is to update style sheets and scripts.

<!-- Recommended -->
-<!DOCTYPE html>
+<!doctype html>
 <title>My first CSS-only redesign</title>
 <link rel="stylesheet" href="default.css">
 <h1>My first CSS-only redesign</h1>
@@ -320,7 +324,7 @@ For consistency and simplicity reasons it’s best served omitting all optional
 tags, not just a selection.)

<!-- Not recommended -->
-<!DOCTYPE html>
+<!doctype html>
 <html>
   <head>
     <title>Spending money, spending bytes</title>
@@ -332,7 +336,7 @@ tags, not just a selection.)

<!-- Recommended -->
-<!DOCTYPE html>
+<!doctype html>
 <title>Saving money, saving bytes</title>
 <p>Qed.