[ About | Licence | Contacts ]
Written by Oleksandr Gavenko (AKA gavenkoa), compiled on 2024-04-01 from rev 052223c22317.


HTML spec

HTML attribute reference (single page).

HTML version declaration

HTML5 version is declared via:

<!doctype html>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

Page encoding

Place in HEAD tag (CHARSET is one among of defined by http://www.iana.org/assignments/character-sets):

<meta http-equiv="Content-Type" content="text/html; charset=CHARSET">

or in HTML 5:

<meta charset="utf-8">


Page or text language

Client may suggest preferred language to server via Accept-Language HTTP tag:

Accept-Language: da, en-gb;q=0.8, en;q=0.7

W3C best practice suggest to surround corresponding text pieces in tag with lang attribute. Attribute values are from BCP 47.

It is good to set language in html tag:

<html lang="en">
Handling character encodings in HTML and CSS (tutorial).
IANA registered language and country codes. Coherent with ISO codes but frequently updates.
Tags for Identifying Languages (Best Current Practice).
Language tags in HTML and XML.
Declaring language in HTML.
Why use the language attribute?

Including CSS and JS fragments and files

HTML 4.01 require type attribute in CSS and JS linking tags:

<link rel="stylesheet" type="text/css" href="path-to.css">
<style type="text/css">...</style>

<script type="text/javascript" src="abc.js"></script>
<script type="text/javascript">...</script>

HTML 5 makes type attribute unnecessary when declaring or linking to external CSS / JS:

<link rel="stylesheet" href="path-to.css">

<script src="abc.js"></script>

Quoting in HTML

In HTML 5 attribute values only need to be quoted if they contain spaces or some non-alphanumeric characters.

HTML 5 support

Look up HTML5, CSS3, etc features, know if they are ready for use, and if so find out how you should use them – with polyfills, fallbacks or as they are.
Modernizr tells you what HTML, CSS and JavaScript features the user’s browser has to offer.
Browser compatibility database of HTML 5 features.

Embedding structural data


<div itemscope itemtype="http://schema.org/Person">
  My name is <span itemprop="name">Random Hacker</span>,
  And I'm a <span itemprop="jobTitle">software developer</span>
Schemas for structured data on the Internet, on web pages, in email messages, and beyond.

Video and audio support

HTML 5 add video and audio tags and corresponding JS API to support video and audio playback.

Media formats supported by the HTML audio and video elements.
HTML5 audio and video widget in Firefox.
Introduction to WebVTT.

Center an object.

To center block-level element:

<div style="margin-left: auto; margin-right: auto; position: relative; width: 700px;">

To center inline element:

<p style="text-align: center;">TEXT</p>

Browser support.