aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-12-06 11:51:09 +0100
committerJohn MacFarlane <[email protected]>2025-12-06 11:51:09 +0100
commit7ced712014b64b59d39e07c82a1633109c05f730 (patch)
tree27cf92fa557d2fa7c245ac4eb2d0efcf06e0af88
parenta3ab4b8545babfb88b9ffda1cfa85de31ddc57ef (diff)
HTML5 template: conditionally include lang attribute.
Previously we included it unconditionally, even if this meant giving it an empty value. This seems at best redundant, since the empty value is the default. At worst, it adds clutter and according to some sources may prevent the use of browser defaults. I believe that the justification for including these attributes even with empty values is not a good one; see commit 07d51d9 for the original change. On my reading, the HTML spec does not require the presence of the attribute on the html element; it only says that if the attribute is present, it must have an empty string or valid BCP 47 language tag as its value. See also #11324.
-rw-r--r--data/templates/default.html52
-rw-r--r--test/writer.html52
2 files changed, 2 insertions, 2 deletions
diff --git a/data/templates/default.html5 b/data/templates/default.html5
index 26740d1b0..7dfa95e87 100644
--- a/data/templates/default.html5
+++ b/data/templates/default.html5
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>
+<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$$if(dir)$ dir="$dir$"$endif$>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
diff --git a/test/writer.html5 b/test/writer.html5
index a7c06813a..a9da62179 100644
--- a/test/writer.html5
+++ b/test/writer.html5
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
+<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />