diff options
Diffstat (limited to 'web/html.md')
-rw-r--r-- | web/html.md | 254 |
1 files changed, 115 insertions, 139 deletions
diff --git a/web/html.md b/web/html.md index f47a0ec..e82634d 100644 --- a/web/html.md +++ b/web/html.md @@ -9,119 +9,6 @@ title: A Quick Guide to Modern HTML Modern HTML is a remarkably simple and coherent standard. -## Basic HTML - -HTML is a *markup language* used for content on the web. It is composed of *tags*, that may be *nested* within each other to form a *document tree*. It is *semantic*: every tag - -and many tags indeed hold no purpose other than indicating ... - - -Every website you visit is composed of HTML, which alongside with styling via CSS... Modern websites are composed of somewhat atrocious amounts of - -Web browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for its appearance. - -HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects such as interactive forms may be embedded into the rendered page. HTML provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes, and other items. HTML elements are delineated by tags, written using angle brackets. Tags such as `<img>` and `<input>` directly introduce content into the page. Other tags such as `<p>` and `</p>` surround and provide information about document text and may include sub-element tags. Browsers do not display the HTML tags but use them to interpret the content of the page. - - -HTML is composed of *tags*. These tags are enclosed in angle brackets - -There are quite a few tags, but not overwhelmingly many. Here they all are. - -if your tag is not reserved, you can kinda just write whatever?? i like doing this - -There are about XX important tags. Here they all are. - -## Style - -- [`<b>`][b] or [`<strong>`][strong]: <b>bold</b> text -- [`<i>`][i] or [`<em>`][em]: <i>italic</i> text -- [`<u>`][u]: <u>underlined</u> text -- [`<s>`][s]: <s>struckthrough</s> text -- [`<q>`][q]: <q>quoted</q> text -- [`<small>`][small]: <small>small</small> text -- [`<sub>`][sub]: <sub>sub</sub>text -- [`<sup>`][sup]: <sup>super</sup>text -- [`<code>`][code]: <code>text styled like code</code> -- [`<pre>`][pre]: <pre>preformatted text</pre> - -Some emphasis must be made: these tags are **semantic**. They are not for styling! You have a much more expressive form of styling with CSS! -Given the existence of a quote key on most ASCII keyboards, this is not very useful, unless you're a stickler for Unicode quotes. - - -<details> -<summary>default styles</summary> - -```css -b, strong { - font-weight: bolder; -} -``` - -```css -i, em { - font-style: italic; -} -``` - -```css -u { - text-decoration: underline; -} -``` - -```css -s { - text-decoration: line-through; -} -``` - -```css -q:before { - content: open-quote; -} - -q:after { - content: close-quote; -} -``` - -```css -small { - font-size: smaller; -} -``` - -```css -sub { - vertical-align: sub; - font-size: smaller; -} -``` - -```css -sup { - vertical-align: super; - font-size: smaller; -} -``` - -```css -code { - font-family: monospace; -} -``` - -```css -pre { - display: block; - font-family: -moz-fixed; - white-space: pre; - margin-block: 1em; -} -``` - -</details> - ## Semantic - [`<html>`][html]: The root of an HTML document. @@ -220,18 +107,16 @@ wbr { </details> -Aside from being block elements, they have no styling... - -- [`<main>`][main] - - There should exist at most one `<main>` element in a document. -- [`<section>`][section] -- [`<aside>`][aside] -- [`<header>`][header] -- [`<footer>`][footer] -- [`<article>`][article] -- [`<nav>`][nav] -- [`<div>`][div]: the generic block container. -- [`<span>`][span]: the generic inline container. +- [`<main>`][main]: The main content of the body of a document. + - There should exist at most one visible `<main>` element in a document. +- [`<header>`][header]: A section of a document intended for treatment as a header. +- [`<footer>`][footer]: A section of a document intended for treatment as a footer. +- [`<aside>`][aside]: A portion of a document only indirectly related to the main content. +- [`<article>`][article]: A self-contained composition within a document. +- [`<nav>`][nav]: A section of the document that provides navigation links. +- [`<section>`][section]: A generic standalone section of the document. +- [`<div>`][div]: The generic block container. `display: block`. +- [`<span>`][span]: The generic inline container. `display: inline` (default). <details> <summary>default styles</summary> @@ -248,18 +133,107 @@ span { </details> +## Stylistic + +- [`<b>`][b] or [`<strong>`][strong]: <b>bold</b> text +- [`<i>`][i] or [`<em>`][em]: <i>italic</i> text +- [`<u>`][u]: <u>underlined</u> text +- [`<s>`][s]: <s>struckthrough</s> text +- [`<q>`][q]: <q>quoted</q> text +- [`<small>`][small]: <small>small</small> text +- [`<sub>`][sub]: <sub>sub</sub>text +- [`<sup>`][sup]: <sup>super</sup>text +- [`<code>`][code]: <code>text styled like code</code> +- [`<pre>`][pre]: <pre style="display: inline; font-size: 0.8em;">preformatted text</pre> + +<details> +<summary>default styles</summary> + +```css +b, strong { + font-weight: bolder; +} +``` + +```css +i, em { + font-style: italic; +} +``` + +```css +u { + text-decoration: underline; +} +``` + +```css +s { + text-decoration: line-through; +} +``` + +```css +q:before { + content: open-quote; +} + +q:after { + content: close-quote; +} +``` + +```css +small { + font-size: smaller; +} +``` + +```css +sub { + vertical-align: sub; + font-size: smaller; +} +``` + +```css +sup { + vertical-align: super; + font-size: smaller; +} +``` + +```css +code { + font-family: monospace; +} +``` + +```css +pre { + display: block; + font-family: -moz-fixed; + white-space: pre; + margin-block: 1em; +} +``` + +</details> + ## Metadata Several HTML elements provide *metadata* about the document in question. They are invisible and removed from the render tree (`display: none`), and only serve to provide information to the browser. -- [`<head>`][head]: the document metadata container. +- [`<head>`][head]: The document metadata container. - There should exist one and only one `<head>` element in a document. -- [`<title>`][title]: the title of the document to be displayed. -- [`<base href="" target="">`][base]: the base URL for all relative URLs to use. +- [`<title/>`][title]: The title of the document to be displayed. +- [`<base href="" target=""/>`][base]: the base URL for all relative URLs to use. - There should exist no more than one `<base>` element in a document. -- [`<link ...>`][link]: establishes relationships between the current document and other external resources. - - This is used for a variety of purposes: site icons, external stylesheets, canonical "next" documents, ... -- [`<meta ...>`][meta]: generic metadata. +- [`<link .../>`][link]: Establishes relationships between the current document and other external resources. + - This is used for a variety of purposes: site icons, external stylesheets, ... +- [`<meta .../>`][meta]: Generic metadata. +- [`<style ...>`][style]: Generic metadata. +- [`<script ...>`][script]: Generic metadata. <details> <summary>default styles</summary> @@ -335,14 +309,6 @@ HTML supports *ordered* and *unordered* lists. - [`<ol type="a" start=1 reversed>`][ol]: An *ordered* list. Displayed as a numbered list by default. - [`<li value=1>`][li]: A *list element*. Nested within either `<ul>` or `<ol>`. -Both ordered and unordered lists should have only `<li>`s as their directly nested elements. - -On ordered lists, the `type` attribute indicates the numbering type, and can be one-of `a` (lowercase letters), `A` (uppercase letters), `i` (lowercase Roman numerals), `I` (uppercase Roman numerals), or `1` (Arabic numerals, default). The `start` attribute indicates the ordinal at which to start labeling at, and must be an Arabic numeral, even when `type` is not the default. The presence of the `reversed` attribute indicates that a list should be labelled in descending order. As usual, these properties all may be overridden with targeted CSS. - -Within ordered lists, the `value` attribute on an `li` indicates that the ordering should jump to the specified ordinal and continue from there. Like `start`, it takes an Arabic numeral, irrespective of ordering style. - -There are also a third type of lists available: *description lists*. These do not use the `<li>` element and are generally left unused. We discuss them in a future section. - <details> <summary>default styles</summary> @@ -375,6 +341,14 @@ ol { </details> +Both ordered and unordered lists should have only `<li>`s as their directly nested elements. + +On ordered lists, the `type` attribute indicates the numbering type, and can be one-of `a` (lowercase letters), `A` (uppercase letters), `i` (lowercase Roman numerals), `I` (uppercase Roman numerals), or `1` (Arabic numerals, default). The `start` attribute indicates the ordinal at which to start labeling at, and must be an Arabic numeral, even when `type` is not the default. The presence of the `reversed` attribute indicates that a list should be labelled in descending order. As usual, these properties all may be overridden with targeted CSS. + +Within ordered lists, the `value` attribute on an `li` indicates that the ordering should jump to the specified ordinal and continue from there. Like `start`, it takes an Arabic numeral, irrespective of ordering style. + +There are also a third type of lists available: *description lists*. These do not use the `<li>` element and are generally left unused. We discuss them in a future section. + ## Hypertext - [`<form ...>`][form]: A section that can perform interactive HTTP requests. @@ -590,6 +564,8 @@ These elements are *really* useless. You shouldn't bother knowing them. They're [base]: https://developer.mozilla.org/HTML/Element/base [link]: https://developer.mozilla.org/HTML/Element/link [meta]: https://developer.mozilla.org/HTML/Element/meta +[style]: https://developer.mozilla.org/HTML/Element/style +[script]: https://developer.mozilla.org/HTML/Element/script [a]: https://developer.mozilla.org/HTML/Element/a [img]: https://developer.mozilla.org/HTML/Element/img [audio]: https://developer.mozilla.org/HTML/Element/audio |