Web Programming Studio Notes

Week 1 - Day 1

1.1: Web History

The internet started as 4 computers in 1969. Early versions of the internet used FTP (File Transfer Protocol) to allow simple files to be transferred.

In the early 1990s Tim Berners-Lee working at CERN developed the World Wide Web, which allowed HTML files to be used to link to other text files, browsers were developed in order to view these files. They are ruled by HTTP (HyperText Transfer Protocol)

Browser Wars Timeline

Cool Website - CSS Zen Garden

1.2: IP addresses, domain names, and URLs

Devices find eachother in networks using IP addresses, these addresses come in multiple forms, mainly IPv4 and IPv6

IPv4 is a 32 bit long address divided into groups of 8 bits, these could range from
0.0.0.0
00000000.00000000.00000000.00000000
to
255.255.255.255
11111111.11111111.11111111.11111111
This differs from IPv6 which uses 128-bit addresses

Typically when using the internet a url will be searched by either the user or the system, this looks to a DNS server in order to retrieve the IP address that correlates with the choses URL. These are stored in the 13 root servers which then propagate to the other DNS servers, often run by the service providers in that country.

Anyone can register a domain name, however most registrars will charge a fee in order to register.

URLs

Domain names are most commonly seen in URLs. A URL (Uniform Resource Locator) is the location of a web resource on the web, such as http://www.cdc.gov/alcohol/faqs.htm. A web resource is any retrievable item, like an HTML file, image, video, CSS stylesheet, etc.

A URL is composed of several parts:

  • Scheme - Characters at the beginning of a URL followed by a colon ":" or a colon and double slashes "://". Common URL schemes include http, https, mailto, and file. Ex: In https://www.cdc.gov/alcohol, the scheme is "https".
  • Hostname - The complete domain name following the scheme in a URL. Ex: In https://www.cdc.gov/alcohol, the hostname is "www.cdc.gov".
  • Path - The characters to the right of the hostname in a URL. Ex: In https://www.cdc.gov/alcohol, the path is "/alcohol".
  • Query string - Optional characters to the right of the question mark (?) in a URL that provide data for the web server. In https://www.youtube.com/watch?v=uu7XCEMdSHg, the characters after the ? tells YouTube's server to play a video having code uu7XCEMdSHg.
  • Fragment - Optional characters at the end of a URL that start with a hash character (#) and refer to a certain location within a webpage. In https://en.wikipedia.org/wiki/URL#History, the fragment "#History" refers to the webpage's History section.

1.3: HTTP

TCP/IP (Transmission Control Protocol/Internet Protocol) Governs how devices communicate over a network, HTTP (HyperText Transfer Protocol) runs over the top of TCP/IP in order to govern the communication between web browsers and web servers.

HTTP Versions

HTTP/1.1 is the HTTP standard used for most of the web's lifetime, but many websites are adopting HTTP/2, a relatively new HTTP standard that speeds-up the transfer of information between web browsers and web servers. HTTP/2 maintains most of HTTP/1.1's semantics. HTTP/3, currently in development, improves the speed of HTTP/2 by using UDP to transport data packets instead of TCP. This material focuses on the basic HTTP workings that all standards share.

Before HTTP starts, the IP address must be found through the DNS lookup, once this occurs it does a TCP handshake in order to establish a connection with the web server. A HTTP request is sent, often requesting html files, images, CSS stylesheets, JavaScript files or videos, a HTTP response responds often with the requested files.

Each item in a website requires one HTTP request in order to retrieve it, for example if a website has an image, a video, a CSS stylesheet and a Javascript File, there will be 5 requests including the HTML document.

HTTP response with HTML in message body

List of HTTP headers

The Internet Assigned Numbers Authority (IANA) is a standards organization that manages various internet numbers and symbols, like global IP address allocation, root zone management in DNS, and media types. IANA maintains a list of HTTP headers that are currently active, obsolete, or experimental.

Browser Caching

In order to reduce loading times browsers often cache files, this is managed by an entity tag system (ETag), the browser will check to see if the ETag has changed between visits, if it matches then the site or content has not changed, if it is different the browser should refresh the content with the new version. When the resource changes, so should the ETag associated with the resource. When a web browser requests a cached web resource, the browser sends the ETag in the request with an If-None-Match header. The web server will reply with a 304 Not Modified response status if the resource has not changed or a 200 OK with the changed resource and a new ETag.

Other caching mechanisms

HTTP defines additional HTTP headers to aid in caching:

  • If-Modified-Since is used with the Last-Modified date/time to request the web server only send the requested resource if the resource has changed since the specified date/time. Ex: "If-Modified-Since: Wed, 01 Sep 2019 13:24:52 GMT" asks the web server to send the resource if the resource was modified after Sep 1, 2019 at 13:24:52 GMT.
  • Expires contains a date/time indicating when the requested resource is considered "stale". Ex: "Expires: Wed, 01 Sep 2019 13:24:52 GMT" tells the web browser to show the cached resource until Sep 1, 2019 at 13:24:52 GMT.
  • Cache-Control is used to specify a number of caching directives. Ex: "Cache-Control: no-store" tells the web browser to never cache the requested resource, and "Cache-Control: max-age=180" tells the browser to cache the resource for 180 seconds.

HTTPS

All HTTP traffic can be viewed by third parties using a network sniffer, these come in all forms however the one most popularly used for showing network traffic when programs are running is Wireshark. HTTPS improves upon this issue by encrypting the traffic between the browser and the web server in order to prevent sniffers from being able to clearly read what is being sent. HTTPS uses Transport Layer Security (TLS) which uses asymmetric public keys to encrypt the data between the browser and web server. In order for a website to use HTTPS, they must aquire a digital certificate from a trusted certificate authority, containing a public key useed by the TLS to encrypt the data

1.4: Web Trends

IoT: Internet Of Things

The Internet of Things (abbreviated as IoT) is the global collection of communicating devices that sense and control technology on behalf of humans. IoT devices range from a simple temperature sensor to a satellite-based laser scanner used to discover archaeological sites hidden by vegetation.

Web accessibility

Web accessibility is the ability of users with disabilities to access and use a webpage with reasonable effort. Designing accessible webpages ensures equal access and opportunity for everyone. Developing accessible webpages requires knowledge of disabilities, assistive technologies and software used by users with disabilities, and following design practices to ensure content is compatible with those assistive tools. Some conditions affecting web accessibility include:

  • Visual problems like blindness, low vision, or color blindness
  • Hand control issues ranging from tremors to total inability to use hands
  • Seizures caused by flashing on the screen
  • Cognitive challenges like dyslexia and other difficulties in processing webpages

Year

Action

Description

1973

Rehabilitation Act (Rehab Act)

Federal law prohibits discrimination based on disability for federal agencies, contractors, and programs that receive federal assistance

1990

Americans with Disabilities Act (ADA)

Federal law states communication with people with disabilities must be "as effective as communication with others"

1998

Rehab Act Section 508

Requires all federal agencies make their websites accessible to people with disabilities, and all computers and phones be accessible to all federal employees

1999

Web Content Accessibility Guidelines (WCAG 1.0)

International standards and recommendations created by the W3C to make web content accessible to people with disabilities

2008

WCAG 2.0

Major update to W3C's web accessibility standards and recommendations that introduces new success criteria

2018

WCAG 2.1

More updates to W3C's web accessibility standards and recommendations that address mobile devices, low vision, cognitive disabilities, and learning impairments

2022

Guidance on Web Accessibility and the ADA

Department of Justice (DOJ) releases guidance on how government agencies and businesses "open to the public" can ensure their websites are accessible, as required by ADA

1.5: Introduction to HTML

Elements

Purpose

Example HTML

h1, h2, h3

Headers. h1 is largest.

<h2>Puppies are cute</h2>

p

Paragraph

<p>Humans seem designed to see puppies as cute.</p>

em, strong

Emphasis (italic), strong emphasis (bold)

When in <strong>doubt</strong>, tell the <em>truth</em>" -Mark Twain

img

Image

<img src="https://resources.zybooks.com/WebProgramming/ducativ1.jpg" alt="Bike photo">

a

Link

<a href="https://www.wikipedia.org/">Click Here</a>

1.6: Introduction to CSS

CSS allows for the developer to change how a webpage looks when displayed in a browser

Common CSS Properties

Properties

Purpose

Example CSS

background-color

Element's background color

h1 {background-color: lightgray;}

color

Element's font color

h1 {color: darkblue;}

font-family

Font used for the element's text.

p {font-family: arial;}

font-size

Font size used for the element's text.

p {font-size: 9pt;}

padding

Spacing between element's content and border.

strong {padding: 5px;}

margin

Spacing around element (outside element's border).

p {margin-left: 10px;}