E D Skinner
Fiction, facts, and philosophy

Amateur radio, astrophotography, bullseye, electronics, family, fiction, music, physics, software, teaching, theology, travel, writing, and many others.

Ed with Chinese lion statue, Wuhan China, Oct-Nov 2003

Html 5 Notes


W3C Validation

HTML 5 webpage(s) may be validated at https://validator.w3.org/.

Guidelines

  • A web page should contain an initial <DOCTYPE html> declaration, an <html lang="html"> wrapper, and therein navigation links in <nav>, a single <body> content, and <footer>.
  • Within the single <body> a web page may contain a single <article> or multiple <section(s)> each of which containing several <article(s)>. (Pre-HTML 5 websites often use <div> instead, but<article> and <section> are now preferred.)
  • HTML5 introduced <article> to semantically mark up things like blog posts, news articles, forum posts, user-submitted comments, or any other standalone item. and should Include an <h[1-6]>...</h[1-6]> within the <article>.
    • An <article> may sometimes contain navigation links in <nav>, more commonly a header in <header>, always main content unencapsulated other than within the <article>, and optional footer content in <footer>.
  • Sections <section> are used to encapsulate multiple <article(s)> in a topically-related list of articles.
    • Some sources suggest <section(s)> may be used to sub-divide the inner parts of an <article>, but this is rarely found.
  • Each webpage should have one and only one <main>, and it should start where the unique page content starts, after the common header/nav, and end after the content’s unique footer, before any common footer begins.
  • (Source:)

Structure

Outer Wrapper

All web pages typically use a similar outer structure.

<DOCTYPE html>
<html lang="html">
    <head>
        ... (Meta-data, links to external resources, styling definitions)
    </head>
    <body>
        <main>
            ... (Inner Content goes here - see below.)
        </main>
    </body>
    <footer>
        ... (Additional links and copyright information)
    </footer>
    <scripts>
        ...
    </scripts>
</html>

Inner Content

Web pages often contain:

<div>
    <header>
		<h[1-6]> ... </h[1-6]> Heading for this list of links to other web pages
		Introductory content for this list
	</header>
	<nav>
		List of links to other web pages
	</nav>
    (Typically there is little or no other content on this type of web page. It's just a list of links to other web pages.)
	<footer>
		Footer for this list of links to other web pages
	</footer>
</div>

Simple Article

<article>
	<header>
		<h[1-6]> ... </h[1-6]> Heading for this simple article
		Introductory content for this simple article (e.g., blog post)
	</header>
	<nav>
		Article-specific links -- i.e., the article's Table of Contents
	</nav>
	Content of this simple article (e.g., blog post) using <h[1-6]> to identify each topic.
	<footer>
		Footer for this simple article (e.g., blog post)
	</footer>
</article>

Series of (Simple) Articles

<section>
	<header>
		<h[1-6] ... </h[1-6]> - Heading for entire series of articles herein
		Introductory content (for entire series of articles herein)
	</header>
	<article>
		As above using <h[1-6]> to identify each topic in this article
	</article>
	<article>
		As above using <h[1-6]> to identify each topic in this article
	</article>
	<article>
		As above using <h[1-6]> to identify each topic in this article
	</article>
	<footer>
		Footer
	</footer>
</section>

Complex Article with Parts in Sections

  • Note: Having <section(s)> within an <article> is unusual.
  • More commonly, <h[1-6]> headings are sufficient to identify the different parts.
<article>
	<header>
		<h[1-6]> ... </h[1-6]> Heading for this entire complex article
		Introductory content for the entire complex article
	</header>
	<section>
		<h[1-6] ... </h[1-6]> Sub-heading for this section of the complex article
		Content of the article's first part using <h[1-6]> to identify each topic in this section
	</section>
	<section>
		<h[1-6] ... </h[1-6]> Sub-heading for this section of the complex article
		Content of the article's second part using <h[1-6]> to identify each topic in this section
	</section>
	<section>
		<h[1-6] ... </h[1-6]> Sub-heading for this section of the complex article
		Content of the article's third part using <h[1-6]> to identify each topic in this section
	</section>
	<footer>
		Footer for this entire complex article
	</footer>
</article>

Containers

  • Many HTML elements within <body> may have container(s):
    • <article class="container"> - Indicates a specific treatment such as a magazine article.
    • <section class="container"> - Indicates a thematic group such as a category containing many related <article(s)>.
    • <header class="container"> - Header information for an article
    • <footer class="container"> - Footer information for an article
    • <nav class="container"> - Navigation menu
    • <aside class="container"> - Side topic
    • <form class="container"> - Form (container)
    • <div class="container"> - Most common in use
  • Types of containers:
    • class=“container” - Sets a max-width at each responsive breakpoint
    • class=“container-fluid” - Sets max-width to the width of the viewport

Basic Multi-Column Layout

Multiple columns example, three across, equal width.

<x class="container"> # x = block element (article, section, div, etc.)
  <x class="row">
   <x class="col">
      Column 1
   </x>
   <x class="col">
      Column 2
   </x>
   <x class="col">
      Column 3
   </x>
 </x>
</x>