VLC 2.9 Foundation

XHTML5 Implementation Guide

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.


1. Basic Setup

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>

2. CSS and Media Types

@media glass {
    /* AR / transparent overlay displays */
}

@media xr {
    /* VR / XR headsets */
}

@media round {
    /* Circular displays */
}

@media handheld {
    /* Low-power devices / engines (not polyfilled) */
}

3. Audio / Video

Self-closing tags

<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" />

Container tags with <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>

4. Embed & Object

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>

5. JavaScript Helpers

elt() — Element Builder

var node = document.elt("div", { class: "box" },
    "Score: ", 42,
    document.elt("span", { style: "color:blue;" }, " points")
);

document.q and document.qs

Function Syntax

function example() {
    console.log("Readable syntax preferred");
}
var thisfunction = function () {
    console.log("Readable syntax preferred");
}

6. Polyfill

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>

7. Summary


Polyfill used: xhtml5.js Demo: xhtml5