Browser

Browser

The dream behind the Web is of a common information space in which we communicate by sharing information. Its universality is essential: the fact that a hypertext link can point to anything, be it personal, local or global, be it draft or highly polished.

Tim Berners-Lee, The World Wide Web: A very short personal history1

Protocols

Styles of communication.

The World Wide Web (www)

Set of protocols for visiting pages. Connecting requires listening on port 80 to HTTP protocol. Documents are named via URL, Uniform Resource Locator, in the form protocol (http), server (quartz.defyingentropy.ml), then path (wiki/browser).

URL: protocol, server, path ip

HTML

Structured tree of tags, called the DOM, Document Object Model. Tags are wrapped in angle brackets <>.

Characters with special meaning, such as angle brackets, are called “entities” and expressed between & and ;, like &lt; for <. As an intellectual writing in markdown, I’m not worried about that.

JS

JS can be included in HTML via the <script> tag. Can either include it literally like

1
<script>alert("Popup!");</script>

or for longer files specify a source:

1
<script src=pop.js></script>

Some HMTL attributes, like button, contain JS attributes.

DOM

Can access the DOM through document with root node document.documentElement. All nodes have a type code:

Good ol' slowly-evolving standard.

Can attach arbitrary attributes to HTML nodes then get with getAttribute(name).

Traversal

Links between DOM nodes

1
2
3
4
5
6
7
<p>My ostrich Gertrude:</p>
<p><img id="gertrude" src="img/ostrich.png"></p>

<script>
  let ostrich = document.getElementById("gertrude");
  console.log(ostrich.src);
</script>

Selectors

CSS selector syntax can be used in querySelector(selector) and querySelectorAll(selector) to find elements.

Editing

Styling

Can change style property of blocks:

1
2
<p><a href=".">Normal link</a></p>
<p><a href="." style="color: green">Green link</a></p>

JS gets access through element.style.property_name, e.g. para.style.color = "magneta". Properties with hyphenation, such as font-family get camelCased, fontFamily.

Fields

CSS

Cascading Style Sheets, named as such because multiple rules are combined to determine the final style, with later rules overruling earlier ones.

Identifiers include .class_name, #id, or simple element. They can be strung together, e.g. p#main.a.b matches a paragraph with id main and classes a and b. Precedence favors specificity.

Notation p > a {...} applies styling to all <a> tags that are children of <p> tags and p a {...} does the same except they can be indirect children.


  1. borrowed from here ↩︎


Interactive Graph