XHTML5 is an extended HTML5 standard using XML syntax while keeping all HTML5 functionality. Its purpose is to maximize readability and flexibility for humans and machines and improve code quality. This is not the final standard or polyfill and is under active development.
Use the proper XML declaration and DOCTYPE:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>My XHTML5 Page</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
</head>
<body>
<!-- Your content here -->
</body>
</html>
<br />
, <img />
, <audio />
, etc.).type="text/css"
for <style>
blocks.@media glass {
/* AR / transparent overlay displays */
}
@media xr {
/* VR / XR headsets */
}
@media round {
/* Circular displays */
}
@media handheld {
/* Low-power devices / engines (not polyfilled) */
}
<audio controls="controls" alt="Audio was not found" src="https://www.nyan.cat/music/dub.mp3" />
<video controls="controls" alt="Video was not found" src="https://www.example.com/video.mp4" />
<img />
.<canvas>
which are normally not.alt=
to be used if the audio/video/etc could not be rendered, allowing the element and error text to be on a single line.<onerror>
is not supported on self-closing tags; use container tags for fallback.<onerror>
<audio controls="controls">
<source src="https://www.nyan.cat/music/dub.mp3" type="audio/mpeg" />
<onerror>
Your browser cannot play this audio.
</onerror>
</audio>
<video controls="controls">
<source src="https://www.example.com/video.mp4" type="video/mp4" />
<onerror>
Your browser cannot play this video.
</onerror>
</video>
<onerror>
wraps fallback content for unsupported media.<source>
/<onerror>
children outside the element to prevent rendering issues.XHTML5 resurrects <object>
and allows <embed>
:
<embed src="file.svg" type="image/svg+xml" />
<embed src="file.svg" type="image/svg+xml"></embed>
<object data="file.svg" type="image/svg+xml"></object>
<img>
, <embed>
, and <object>
could also support <source>
and <onerror>
.elt()
— Element Buildervar node = document.elt("div", { class: "box" },
"Score: ", 42,
document.elt("span", { style: "color:blue;" }, " points")
);
document.q
and document.qs
document.q(selector)
: alias for document.querySelector()
document.qs(selector)
: alias for document.querySelectorAll()
() => {}
) are discouraged for readability.function example() {
console.log("Readable syntax preferred");
}
var thisfunction = function () {
console.log("Readable syntax preferred");
}
XHTML5 is not implemented yet, so for testing, include the polyfill in your page:
<script type="text/javascript" src="https://vlc29.neocities.org/xhtml5.js"></script>
document.xhtml5 = true
if not already present.Implements:
elt()
q()
and qs()
<audio>
and <video>
container elements for fallback handlingglass
, xr
, round
)<img />
<onerror>
provides fallback content for media