HyperText Markup Language is a web format commonly identified by .html, .htm. Use the listed signatures, MIME types, and structure notes to validate files beyond the extension.
offset 0HyperText Markup Language leading signature
3C 21 64 6F 63 74 79 70 65
<!doctype
Structure
Doctype
html
head
body
Caveats
Do not trust the extension alone. Check the MIME type, the first bytes such as 3C 21 64 6F 63 74 79 70 65, and format-specific structure when possible.
Container formats and damaged files can share the same opening bytes, so deeper validation may be required for production upload, preview, or conversion flows.
Detection example
SIGNATURE = bytes.fromhex("3c21646f6374797065")
OFFSET = 0
def is_html(path: str) -> bool:
with open(path, "rb") as f:
f.seek(OFFSET)
head = f.read(len(SIGNATURE))
return head == SIGNATURE
const SIGNATURE = [0x3c, 0x21, 0x64, 0x6f, 0x63, 0x74, 0x79, 0x70, 0x65];
const OFFSET = 0;
// bytes: a Uint8Array / Buffer holding the start of the file
export function isHtml(bytes) {
return SIGNATURE.every((byte, i) => bytes[OFFSET + i] === byte);
}
HyperText Markup Language is used for data exchange, imports, exports, parser testing, and validation workflows. Encoding, delimiters, versions, and container structure often change implementation behavior.
Common detection mistakes
The .html / .htm extension alone does not prove the file contents. Upload and conversion flows should combine extension, MIME type, leading bytes, and format-specific structure checks.
HyperText Markup Language can start with signatures such as 3C 21 64 6F 63 74 79 70 65, but related containers and damaged files may require additional validation.
Security notes
Untrusted input is not safe just because the format was detected. Account for parser exceptions, large files, unexpected encodings, and external references.
Using samples
11 samples help test leading-byte detection, parser errors, upload limits, and download behavior.
Blue Sky HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Flower Garden HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Navy Blue Sky HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Nature of the Sky HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Sky Landscape HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Starry Sky HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Blue Night Sky HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Hibiscus Flower HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Arctic Sky HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Sunset Rays HTML is a HyperText Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
NASA Blue Marble HTML is a HyperText Markup Language sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.
What is the magic number (file signature) of HyperText Markup Language?
HyperText Markup Language files begin with the byte signature 3C 21 64 6F 63 74 79 70 65 ("<!doctype"). Detect the format by reading these leading bytes rather than trusting the file extension alone.
What is the MIME type of HyperText Markup Language?
The MIME type for HyperText Markup Language is text/html.
What file extension does HyperText Markup Language use?
HyperText Markup Language files use the .html, .htm extension. The extension is a convention only and does not guarantee the file contents, so combine it with signature and structure checks.