class: center, middle # HTML, CSS, and Agile __CS291A__ Dr. Bryce Boe October 5, 2017 --- # Today's Agenda * [Finish HTTP Lecture](/slides/2017/02_http/#51) * TODO * HTTP Review * Introduction to HTML * Introduction to CSS * Agile Software Development --- # TO-DO ## Should be done * [Piazza](https://piazza.com/class/j789lo09yai5qx) / [Ruby Code Academy](https://www.codecademy.com/tracks/ruby) * Chapters 1 & 2 in [HPBN](https://hpbn.co/primer-on-latency-and-bandwidth/) / Chapter 1 in the [Ruby on Rails Tutorial](https://www.railstutorial.org/book/beginning) ## Before Tuesday's Lecture * Read/review Chapters 9 through 11 in [HPBN](https://hpbn.co/brief-history-of-http/) ## Before Next Week's Lab: * Complete Chapters 2 through 6 in the [Ruby on Rails Tutorial](https://www.railstutorial.org/book/toy_app) * Learn [git](http://rogerdudler.github.io/git-guide/) * Your team's github should have a single-controller app and a README with project description, and team member photos. --- # HTTP Components Review  --- # Chrome Network Table  --- # Review > Why is the HOST header required in HTTP 1.1? > What are the issues with using a TCP connection for each HTTP request? > What is domain sharding? --- class: center inverse middle # Introduction to HTML --- # HyperText Markup Language Plain text language that uses SGML syntax with a defined set of _tags_. * Mark-up is provided by nesting text and other mark-up between `
` and `
` * Tags are nestable * Tags can have key-value attributes Example: ```html
Header 1
Header 3
A paragraph with some
emphasized text
.
``` --- # HTML Document HTML documents single root-element _should_ be the `` tag. Its forest of children are referred to as the _Document Object Model_ or __DOM__. Technically there should be only two children of an `` tag: ``: Encapsulates meta-data about the page including its title, and references to external resources (CSS, JavaScript) ``: Encapsulates everything to be displayed on the page __Note__: With HTML5 (and many browsers' parsers for other variations of HTML) these first-level tags can be omitted as they can be inferred based on the tag being used. --- # HTML5 Bootstrap Example ```html
Bootstrap 101 Template
Hello, world!
``` --- # Common HTML Tags Different HTML tags should be used for different elements on the page. There exist a handful of formatting and style tags, however, those should be avoided in-favor of using CSS (cascading style sheets) -- we will discuss CSS later. * __h1__ through __h6__: various header-level tags (h1 should be page title) * __p__: paragraph text * __ul__, __ol__: unordered and ordered list wrapper * __li__: list item (nested within ul, or ol) * __table__: begin a table * __tr__: begin a table row within a table * __td__: one entry in a table row * __span__: An inline grouping mechanism * __div__: A block-level grouping mechanism --- # Anchor Tag The most innovative part about HTML is the __HyperText__ part provided by the anchor tag: `
` Using an anchor tag one can link to another document (resource) anywhere on the web. ```html
CS291A
``` --- # HTML Forms An HTML form provides a convenient way to collect input from a web browser. ```html
Name
``` ## Notes * `method` defaults to __GET__. Recall that __GET__ requests shouldn't have side-effects so __POST__ is more-often more appropriate. * The default encoding is `application/x-www-form-urlencoded` --- # Attributes `id` and `class` HTML elements have two ubiquitous tags: `id`: A unique identifier that makes it easy to find one element in the DOM `class`: Multiple classes can be assigned to DOM elements, and the same class can be applied to multiple DOM elements (many-to-many relationship). ```html
Error
``` DOM IDs and classes are very useful for applying CSS, and adding JavaScript callback hooks to elements on the page. --- class: center inverse middle # Introduction to Cascading Style Sheets (CSS) --- # The `
Hello World
``` --- # Style via ID DOM elements can be styled multiple ways. Here we are styling all DOM elements with ID `header` (there should be at most one per page). IDs are prefixed with the `#` symbol in CSS. ```html
Hello World
``` --- # Style via Class Here we are styling all DOM elements with class `alert`. Classes are prefixed with the `.` symbol in CSS. ```html
Hello World
``` --- # Inline Styles We can use the `style` attribute on HTML tags to directly style DOM elements. ```html
Hello World
``` --- # Contradictory Styles ```html
Hello World
``` > What color is Hello World? --- # Simplified Rule Precedence In general more specific rules have higher precedence than less specific rules. Precedence order (highest first): * `!important` rules (e.g., `span {color: blue !important};`) * Inline style * ID * Class * HTML Tag It gets more complicated, but understanding these rules will go a long way. --- # External Style Sheets Style definitions are most often provided through separate CSS files, rather than `