Documentation
A good test of this stylesheet is to try out all of the tags. Here is the tag reference from Mozilla with demo code and examples of how each tag is styled.
There are also CSS variables for the main colours, so if you need to retheme the colour scheme you can!
Head, body, meta code
Metadata contains information about the page. This includes information about styles, scripts and data to help software (search engines, browsers, etc.) use and render the page. Metadata for styles and scripts may be defined in the page or link to another file that has the information.
<html>The HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element. All other elements must be descendants of this element.
<base> elements specify the base URL to use for all relative URLs in a document.
<head> elements contains machine-readable information (metadata) about the document, like its title, scripts, and style sheets.
<link> The HTML External Resource Link element specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets, but is also used to establish site icons (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
<style> elements contain style information for a document, or part of a document.
<title> defines the document's title that is shown in a browser's title bar or a page's tab.
<meta> elements represent metadata that cannot be represented by other HTML meta-related elements, like <base>, <link>, <script>, <style> or <title>.
<body> element represents the content of an HTML document. There can be only one in a document.
Demo
You're already seeing it, but a lot of the head / meta content isn't visible directly...
View example source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>GDCSS Documentation</title> <meta name="description" content="Documentation for a tags-only CSS library" /> <meta name="author" content="Stephen Hawkes" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="theme-color" content="#000000" /> <link href="gd.css" rel="stylesheet"> </head>
Content sectioning
Content sectioning elements allow you to organize the document content into logical pieces. Use the sectioning elements to create a broad outline for your page content, including header and footer navigation, and heading elements to identify sections of content.
Layout
Really HTML is about semantics, but these particular tags have been styled in so that they also produce common layout patterns.
<article> elements represent a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication).
<aside> elements represents a portion of a document whose content is only indirectly related to the document's main content.
<footer> elements represents a footer for its nearest sectioning content or sectioning root element. A footer typically contains information about the author of the section, copyright data or links to related documents.
<header> elements represent introductory content, typically a group of introductory or navigational aids. It may contain some heading elements but also a logo, a search form, an author name, and other elements.
<main> elements represent the dominant content of the <body> of a document. The main content area consists of content that is directly related to or expands upon the central topic of a document, or the central functionality of an application.
<nav> elements represent a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.
Demo
View example source
<body> <header> Body > HEADER <nav>Header nav</nav> </header> <nav>Body NAV</nav> <main> <header>Body HEADER</header> Body <section> <article>ARTICLE</article> <aside>ASIDE</aside> </section> </main> <footer> Footer <main>Footer MAIN</main> </footer> </body>
<section> elements represents a standalone section — which doesn't have a more specific semantic element to represent it — contained within an HTML document. We use this to denote subdivisions or 'sections' as a way to create extra layouts without messing up semantics. In short, this tag just creates a CSS grid layout for child elements.
Demo
View example source
<section> <aside> <p>Aside 1</p> </aside> <aside> <p>Aside 2</p> </aside> <aside> <p>Aside 3</p> </aside> </section>
Headings
<h1>, <h2>, <h3>, <h4>, <h5>, <h6> The HTML <h1>–<h6> elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.
Demo
View demo
Heading One
Heading Two
Heading Three
Heading Four
Heading Five
Heading Six
View example source
<h1>Heading One</h1> <h2>Heading Two</h2> <h3>Heading Three</h3> <h4>Heading Four</h4> <h5>Heading Five</h5> <h6>Heading Six</h6>
<hgroup> elements represent a multi-level heading for a section of a document. It groups a set of <h1>–<h6> elements. We use this grouping to show the combination style variants of the headers.
Demo
Some title smaller
Big heading
View example source
<hgroup> <h4>Some title smaller</h4> <h1>Big heading</h1> </hgroup>
Text content
Use HTML text content elements to organize blocks or sections of content placed between the opening <body> and closing </body> tags. Important for accessibility and SEO, these elements identify the purpose or structure of that content.
<address> elements indicate that the enclosed HTML provides contact information for a person or people, or for an organisation.
Demo
Steve Hawkessteve@dev.ngo
+44 (0) 333 344 7800
View example source
<address> Steve Hawkes<br /> <a href="mailto:steve@dev.ngo">steve@dev.ngo</a><br> <a href="tel:+443333447800">+44 (0) 333 344 7800</a> </address>
<blockquote> elements (or Block Quotation Element) indicates that the enclosed text is an extended quotation. Usually, this is rendered visually by indentation (see Notes for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the <cite> element.
<q> elements indicate that the enclosed text is a short inline quotation. Most modern browsers implement this by surrounding the text in quotation marks.
<cite> The HTML Citation element is used to describe a reference to a cited creative work, and must include the title of that work.
Demo
Make your service look and feel like GOV.UK.GOV.UK Design System team
View example source
<blockquote cite="https://design-system.service.gov.uk/styles/"> <q>Make your service look and feel like GOV.UK.</q> <cite>GOV.UK Design System team</cite> </blockquote>
Containers for styling
<div> The HTML Content Division element is the generic container for flow content. It has no effect on the content or layout until styled using CSS. They do nothing in GDCSS, because they don't carry any meaning. They can be useful in combination with <section> tags to manage the CSS grid.
<span> elements are a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang.
<dl> elements represent a description list. The element encloses a list of groups of terms and descriptions. Common uses for this element are to implement a glossary or to display metadata (a list of key-value pairs).
<dt> elements specify a term in a description or definition list.
<dd> elements provide the description, definition, or value for the preceding term in a description list.
Demo
- Definition term 1
- Definition description 1
- Definition term 2
- Definition description 2
- Definition term 3
- Definition description 3
View example source
<dl> <dt>Definition term 1</dt> <dd>Definition description 1</dd> <dt>Definition term 2</dt> <dd>Definition description 2</dd> <dt>Definition term 3</dt> <dd>Definition description 3</dd> </dl>
<figure> (Figure With Optional Caption) element represents self-contained content, potentially with an optional caption.
<figcaption> or Figure Caption element represents a caption or legend describing the rest of the contents of its parent <figure> element.
Demo
View example source
<figure> <img src="https://via.placeholder.com/960x320" alt="The figure tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc."> <figcaption>The figcaption tag defines a caption for a figure element.</figcaption> </figure>
<hr> elements represent a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section. You can see them between each area on this page.
View example source
<hr />
<ul> elements represent an unordered list of items, typically rendered as a bulleted list.
<ol> elements represent an ordered list of items — typically rendered as a numbered list.
<li> elements is used to represent an item, normally in an ordered or unordered list.
Demo
- unordered one
- unordered one
- ordered one
- ordered two
View example source
<ul> <li>unordered one</li> <li>unordered one</li> </ul> <ol> <li>ordered one</li> <li>ordered two</li> </ol>
<p> elements represent a paragraph. This line of text is in a paragraph.
View example source
<p>Some text and inline elements here.</p>
<pre> elements represents preformatted text which is to be presented exactly as written in the HTML file.
Demo
Some text where the indentation matters to and isn't altered by the browser...
View example source
<pre>Some text where the indentation matters to and isn't altered by the browser...</pre>
Inline text semantics
Use the HTML inline text semantic to define the meaning, structure, or style of a word, line, or any arbitrary piece of text.
<a> elements (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.
Demo
We see these a lot on, here is your common link, standard variety. To make things more fun, we also added some extra cases based on how you use them: External links, Back links, and Top links for common icon inclusion.
View example source
<p>We see these a lot on, here is your <a href="#">common link</a>, standard variety. To make things more fun, we also added some extra cases based on how you use them: <a href="https://gov.uk/">External links</a>, <a href="javascript:history.back()">Back links</a>, and <a href="#top">Top links</a> for common icon inclusion.</p>
Emphasis
<b> The HTML Bring Attention To element is used to draw the reader's attention to the element's contents, which are not otherwise granted special importance.
<strong> The HTML Strong Importance Element indicates that its contents have strong importance, seriousness, or urgency. Browsers typically render the contents in bold type.
<em> elements mark text that has stress emphasis. It can be nested, with each level of nesting indicating a greater degree of emphasis.
<i> elements represent a range of text that is set off from the normal text for some reason.
Demo
There's lots of ways to show emphasis with bold, strong tags varying weight and em and italics for text styles.
View example source
<p>There's lots of ways to show emphasis with <b>bold</b>, <strong>strong</strong> tags varying weight and <em>em</em> and <i>italics</i> for text styles.</p>
Code and outputs
<code> elements display its contents styled in a fashion intended to indicate that the text is a short fragment of computer code.
<kbd> The HTML Keyboard Input element represents a span of inline text denoting textual user input from a keyboard, voice input, or any other text entry device.
<mark> The HTML Mark Text element represents text which is marked or highlighted for reference or notation purposes, due to the marked passage's relevance or importance in the enclosing context.
<var> The HTML Variable element represents the name of a variable in a mathematical expression or a programming context.
<samp> The HTML Sample Element is used to enclose inline text which represents sample (or quoted) output from a computer program.
<data> elements link a given content with a machine-readable translation. If the content is time- or date-related, the <time> element must be used. Nothing visible, but adds semantic expression.
<time> elements represent a specific period in time. Nothing visible, but adds semantic expression.
Demo
Code here
kbd here
mark here
Var here
Samp here
Twenty Three Tags
View example source
<p><code>Code here</code><br /> <kbd>kbd here</kbd><br /> <mark>mark here</mark><br /> <var>Var here</var><br /> <samp>Samp here</samp><br /> <data value="23">Twenty Three Tags</data><br /> <time datetime="PT2H30M">2h 30m</time></p>
Special word semantics
<abbr> The HTML Abbreviation element represents an abbreviation or acronym; the optional title attribute can provide an expansion or description for the abbreviation.
<dfn> The HTML Definition element is used to indicate the term being defined within the context of a definition phrase or sentence.
Demo
An abbreviation is when text is reduced obvs! It's also slang...
View example source
<p>A <dfn>abbreviation</dfn> is when text is reduced <abbr title="obviously">obvs</abbr>! It's also slang...</p>
Smaller semantics
<small> elements represent side-comments and small print, like copyright and legal text, independent of its styled presentation. By default, it renders text within it one font-size smaller, such as from small to x-small.
<sub> The HTML Subscript element specifies inline text which should be displayed as subscript for solely typographical reasons.
<sup> The HTML Superscript element specifies inline text which is to be displayed as superscript for solely typographical reasons.
Demo
Some text needs to be small, some above the line like E=mc2.
And some below, like H2SO4.
View example source
<p>Some text needs to be <small>small</small>, some above the line<sup>*</sup>, like E=mc<sup>2</sup>.</p> <p>And some below, like H<sub>2</sub>SO<sub>4</sub>.</p>
Text decoration
<u> The HTML Unarticulated Annotation Element represents a span of inline text which should be rendered in a way that indicates that it has a non-textual annotation.
<s> elements render text with a strikethrough, or a line through it. Used to represent things that are no longer relevant or no longer accurate. However, it is not appropriate when indicating document edits; for that, use the <del> and <ins> elements, as appropriate.
Demo
These tags are styled as an underline or a strikethrough.
View example source
<p>These tags are styled as an <u>underline</u> or a <s>strikethrough</s>.</p>
White space and containers
<br> elements produce a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.
<wbr> elements represent a word break opportunity— a position within text where the browser may optionally break a line, though its line-breaking rules would not otherwise create a break at that location.
Language
<bdi> The HTML Bidirectional Isolate element tells the browser's bidirectional algorithm to treat the text it contains in isolation from its surrounding text.
<bdo> The HTML Bidirectional Text Override element overrides the current directionality of text, so that the text within is rendered in a different direction.
<ruby> elements represents a ruby annotation. Ruby annotations are for showing pronunciation of East Asian characters.
<rb> The HTML Ruby Base element is used to delimit the base text component of a <ruby> annotation, i.e. the text that is being annotated.
<rp> The HTML Ruby Fallback Parenthesis element is used to provide fall-back parentheses for browsers that do not support display of ruby annotations using the <ruby> element.
<rt> The HTML Ruby Text element specifies the ruby text component of a ruby annotation, which is used to provide pronunciation, translation, or transliteration information for East Asian typography. The <rt> element must always be contained within a <ruby> element.
<rtc> The HTML Ruby Text Container element embraces semantic annotations of characters presented in a ruby of <rb> elements used inside of <ruby> element. <rb> elements can have both pronunciation (<rt>) and semantic (<rtc>) annotations.
Demo
- Evil Steven: 1st place
- François fatale: 2nd place
- تیز سمی: 3rd place
- الرجل القوي إيان: 4th place
- تیز سمی: 5th place
The English song "Oh I do like to be beside the seaside"
Looks like this in Hebrew: אה, אני אוהב להיות ליד חוף הים
In the computer's memory, this is stored as אה, אני אוהב להיות ליד חוף הים
View example source
<ul> <li><bdi class="name">Evil Steven</bdi>: 1st place</li> <li><bdi class="name">François fatale</bdi>: 2nd place</li> <li><span class="name">تیز سمی</span>: 3rd place</li> <li><bdi class="name">الرجل القوي إيان</bdi>: 4th place</li> <li><span class="name" dir="auto">تیز سمی</span>: 5th place</li> </ul> <p>The English song "Oh I do like to be beside the seaside"</p> <p>Looks like this in Hebrew: <span dir="rtl">אה, אני אוהב להיות ליד חוף הים</span></p> <p>In the computer's memory, this is stored as <bdo dir="ltr">אה, אני אוהב להיות ליד חוף הים</bdo></p> <ruby> <rb>漢<rb>字 <rp>(</rp><rt>kan<rt>ji<rp>)</rp> </ruby> <rtc xml:lang="en" style="ruby-position: over;"> <rp>(</rp><rt>Malaysia</rt><rp>)</rp> </rtc>
Image and multimedia
HTML supports various multimedia resources such as images, audio, and video.
Image maps
<area> elements define a hot-spot region on an image, and optionally associates it with a hypertext link. This element is used only within a <map> element.
<map> elements are used with <area> elements to define an image map (a clickable link area).
Demo
Haven't included a demo here, as they're not great responsively without some javascript to adjust sizes.
View example source
<img src="workplace.jpg" alt="Workplace" usemap="#workmap"> <map name="workmap"> <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm"> <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm"> <area shape="circle" coords="337,300,44" alt="Coffee" href="coffee.htm"> </map>
Image, audio & motion
<audio> elements are used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the <source> element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream.
<picture> elements contains zero or more <source> elements and one <img> element to offer alternative versions of an image for different display/device scenarios.
<video> The HTML Video element embeds a media player which supports video playback into the document. You can use <video> for audio content as well, but the <audio> element may provide a more appropriate user experience.
<source> elements specify multiple media resources for the <picture>, the <audio> element, or the <video> element.
<track> elements are used as a child of the media elements <audio> and <video>. It lets you specify timed text tracks (or time-based data), for example to automatically handle subtitles. The tracks are formatted in WebVTT format (.vtt files) — Web Video Text Tracks or Timed Text Markup Language (TTML).
<img> The HTML image element embeds an image into the document.
Demo
View example source
<figure> <picture> <source srcset="https://via.placeholder.com/960x150" media="(min-width: 800px)"> <img src="https://via.placeholder.com/720x150" /> </picture> <figcaption>Placeholder image</figcaption> </figure> <figure> <audio controls> <source src="audio.mp3" type="audio/mp3"> <source src="audio.ogg" type="audio/ogg"> Your browser does not support the <code>audio</code> element. </audio> <figcaption>Simple piano melody</figcaption> </figure> <figure> <video controls> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> <track default kind="captions" srclang="en" src="cue.vtt" /> Sorry, your browser doesn't support embedded videos. </video> <figcaption>City traffic at night</figcaption> </figure>
Embedded content
In addition to regular multimedia content, HTML can include a variety of other content, even if it's not always easy to interact with.
<embed> elements place external content at the specified point in the document. This content is provided by an external application or other source of interactive content such as a browser plug-in.
<object> elements represent an external resource, which can be treated as an image, a nested browsing context, or a resource to be handled by a plugin.
<param> The HTML parameter element defines parameters for an <object> element.
<iframe> The HTML Inline Frame element represents a nested browsing context, embedding another HTML page into the current one.
Generally objects and embeds are tricky for compatibility because it's hard to guarentee what the browser can renders, so not a huge amount of effort her went into styling here.
Demo
View example source
<iframe title="Inline Frame Example" src="iframe.html"></iframe>
Scripting
In order to create dynamic content and Web applications, HTML supports the use of scripting languages, most prominently JavaScript. Certain elements support this capability.
<canvas> elements with either the canvas scripting API or the WebGL API to draw graphics and animations.
<noscript> elements defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.
<script> elements are used to embed or reference executable code; this is typically used to embed or refer to JavaScript code.
Demo
View example source
<canvas id="clock" width="150" height="150"> <img src="https://via.placeholder.com/150x150" width="150" height="150" alt="Canvas Fallback"/> </canvas> <script type="text/javascript"> function draw() { var canvas = document.getElementById('tutorial'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.fillRect(25, 25, 100, 100); ctx.clearRect(45, 45, 60, 60); ctx.strokeRect(50, 50, 50, 50); } } </script> <noscript> <p>You don't have javascript enabled.</p> </noscript>
Demarcating edits
These elements let you provide indications that specific parts of the text have been altered.
<del> elements represent a range of text that has been deleted from a document.
<ins> elements represent a range of text that has been added to a document.
Demo
This is a smart pargraph of text with some hacked-in edits.
View example source
<p>This is a <ins>smart</ins> pargraph of text with some <del>hacked-in</del> edits.</p>
Table content
The elements here are used to create and handle tabular data.
<caption> elements specify the caption (or title) of a table.
<col> The HTML column element defines a column within a table and is used for defining common semantics on all common cells. It is generally found within a <colgroup> element.
<colgroup> The HTML Column Group element defines a group of columns within a table.
<table> elements represent tabular data — that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.
<tbody> The HTML Table Body element encapsulates a set of table rows, indicating that they comprise the body of the table.
<td> or Table Data element defines a cell of a table that contains data. It participates in the table model.
<tfoot> elements define a set of rows summarizing the columns of the table.
<th> elements define a cell as header of a group of table cells. The exact nature of this group is defined by the scope and headers attributes.
<thead> element defines a set of rows defining the head of the columns of the table.
<tr> elements define a row of cells in a table. The row's cells can then be established using a mix of <td> (data cell) and <th> (header cell) elements.
Demo
Items | Expenditure |
---|---|
Donuts | 3,000 |
Stationery | 18,000 |
Totals | 21,000 |
View example source
<style> .highlight { background: var(--color-access);} </style> <table> <caption style="caption-side:bottom">All the numbers in a table</caption> <colgroup> <col> <col span="1" class="highlight"> </colgroup> <thead> <tr> <th>Items</th> <th scope="col">Expenditure</th> </tr> </thead> <tbody> <tr> <th scope="row">Donuts</th> <td>3,000</td> </tr> <tr> <th scope="row">Stationery</th> <td>18,000</td> </tr> </tbody> <tfoot> <tr> <th scope="row">Totals</th> <td>21,000</td> </tr> </tfoot> </table>
Forms
HTML provides a number of elements which can be used together to create forms which the user can fill out and submit to the Web site or application. There's a great deal of further information about this available in the HTML forms guide.
<button> elements represent a clickable button, used to submit forms or anywhere in a document for accessible, standard button functionality.
<datalist> elements contains a set of <option> elements that represent the permissible or recommended options available to choose from within other controls.
<fieldset> elements are used to group several controls as well as labels within a web form.
<form> elements represents a document section containing interactive controls for submitting information.
<input> elements are used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent.
<label> elements represent a caption for an item in a user interface.
<legend> elements represent a caption for the content of its parent <fieldset> tag.
<meter> elements represent either a scalar value within a known range or a fractional value.
<optgroup> elements create a grouping of options within a <select> element.
<option> elements are used to define an item contained in a <select>, an <optgroup>, or a <datalist> element. As such, <option> can represent menu items in popups and other lists of items in an HTML document.
<output> The HTML Output element is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.
<progress> elements display an indicator showing the completion progress of a task, typically displayed as a progress bar.
<select> elements represent a control that provides a menu of options
<textarea> elements represent a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example a comment on a review or feedback form.
Demo
Interactive elements
HTML offers a selection of elements which help to create interactive user interface objects.
<details> The HTML Details Element creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. You can see these for each of the demo sections n this page.
<summary> The HTML Disclosure Summary element element specifies a summary, caption, or legend for a <details> element's disclosure box.
View example source
<details> <summary>View example source</summary> <pre>code goes here</pre> </details>