I want to start creating websites again, but I've been out of the HTML scene for a while now. I was just wondering if this is a good skeleton for a website. And if not, what should I change, add and/or remove?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<rel="stylesheet" type="text/css" href="css/main.css" />
<meta http-equiv="content-type" content="text/php; charset=utf-8" />
<title>Site Template - Welcome!</title>
</head>
<body>
<div class="Container">
<div class="Header">
</div>
<div class="Menu">
<ul id="nav">
<li>menu item</li>
<li>menu item</li>
<li>menu item</li>
<li>menu item</li>
<li>menu item</li>
<li>menu item</li>
</ul>
</div>
<div class="Body">
</div>
</div>
</body>
<footer>
<div class="Footer">
<b>Copyright - 2010</b>
</div>
</footer>
</html>
There is nothing like a
<footer>
element in XHTML 1.0 Transitional. You should do it like this:I like to use a strict doctype in my projects, but yours works, too.
tl;dr
An HTML5 skeleton could look like this:
(Note that this is not the most minimal HTML5 document, so many parts are optional.)
If you are using a different encoding than UTF-8, change the value of the
meta
-charset
accordingly.If you are using a different content language than English, change the value of the
lang
attribute accordingly.If you want to explicitly specify the text directionality, use the
dir
attribute on thehtml
element, e.g.:<html dir="ltr" lang="en">
Common
link
/meta
elements to add to thehead
Linking to a stylesheet (
text/css
is assumed by default):Linking to a favicon:
Specifying the canonical URL of the document:
Providing a description of the page’s content:
Elements for the
body
As each page is different, this can‘t be answered generally, so it might be best to leave the
body
empty.However, most pages probably are part of a website, and most websites probably have a site-wide header (→
header
) with site name (→h1
), footer (→footer
) and navigation menu (→nav
). These should belong to thebody
sectioning root (i.e., have no other sectioning content element as parent). Thenav
may or may not be part of theheader
.The main content (→
main
) may or may not consist of a sectioning element (usuallyarticle
orsection
, or multiple of them).I've been starting with HTML5 Boilerplate... it helps make sure that everything is the most consistent across the various browsers and already takes into account the majority of the stuff I'll need later.
Try www.htmlshell.com, you can get a basic skeleton there, with optional includes for things like jQuery or favicons, etc.
The W3C DOM Level 1 Core is a good place to start:
From there you can add any option (
<html lang="en">
,<meta charset="utf-8">
, etc.), element (link
,main
,nav
,div
,footer
, etc.) or library dependency (jQuery, Bootstrap, etc.), based on your needs and preferences.