Study Vault Search notes, aliases and full text
Graph
ConceptDBISAI-written · not yet proofread

HTML Structure

Also HTML · CSS

HTML (Hypertext Markup Language) is the XML-like language that specifies the content of a web page as nested tagged elements, with meta information, style (CSS) and script includes in the head and the visible content in the body.

Formula#

Minimal valid page#

<html>
  <head>
    <meta charset="utf-8">
    <style>/* CSS rules */</style>
    <link rel="stylesheet" type="text/css" href="search.css"/>
    <script src="script.js" defer></script>
  </head>
  <body>
    <h1>Title</h1>
    <p id="content">Text</p>
  </body>
</html>

Key elements#

ElementPurposeKey attributes
<h1>level-1 heading
<p>paragraph of textid
<div>arbitrary “logical” sectionid, class
<input>input fieldid, type, name, value
<button>clickable button
<form>groups inputs for submission (HTML Form)method, action
<a>linkhref
<style>inline CSS definitionsplaced in <head>
<link>include a stylesheetrel="stylesheet", href
<script>JavaScript, inline or from a filesrc for external, defer
<meta>meta informationcharset="utf-8"

CSS#

CSS (Cascading Style Sheets) specifies style (layout, font, colour, …) independently of the content, in its own simple syntax selector { property: value; … }:

h1 { color: blue; font-weight: bold }    /* all level-1 headings blue and bold */
#result { background: lightgray }         /* the element with id "result" */

Cascading: when several rules apply to the same element, the most specific one wins. CSS goes into <style> in the head or into a separate file included with <link rel="stylesheet" …> (served with media type text/css).

Properties#

  • <head> contains metadata, styles and script references; <body> contains all visible content.
  • The id attribute uniquely identifies an element for CSS selectors (#id) and JavaScript access (DOM Manipulation).
  • The name attribute on <input> determines the query parameter key when submitted via an HTML Form.
  • Script placement. Inline <script>…</script> and <script src> without defer are executed as soon as they are encountered. With defer, the script runs after the whole HTML has been parsed and the DOM constructed. A script in <head> without defer cannot find body elements; put it at the end of <body> or add defer.
  • <meta charset="utf-8"> declares the Character Encoding of the page; if it does not match the bytes of the file, special characters are garbled (ä instead of ä).

Example#

Sources#

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only