Html documentation

The three pillars of writing good CSS

  1. Responsive design
    • Fluid layouts
    • Media queries
    • Responsive images
    • Correct units
    • Desktop first vs mobile first
  2. Maintainable & scalable code
    • Clean
    • Reusable
    • How to organize files
    • How to name classes
    • How to structure HTML
  3. Web performance
    • Less http requests
    • Less code
    • Compress code
    • Use a CSS pre‐processor
    • Less images
    • Compress images

What happens when we load a webpage?

css process

Http requests

HTTP stands for Hyper Text Transfer Protocol. Is it what happens when you access a website. Fetching data from web servers.

Http process

Someone enters a URL in the web browser, the computer then requests data from servers and the server sends back code. Finally the browser turns the code into human readable website.

Html basics

Divs & spans

  1. <div> is a block level elements that group content together. Div means 'divisional elements'.
  2. <span> is an inline level elements that group content together.
  3. In Elementor, each section is a section element, then each column is a div. If a section only has one column, no section element is needed, just a div.

Hr, br, sup & sub


  1. <hr> is a horizontal rule with no closing tags. Create a line or a divider between elements. HR is a block level element.
  2. <br> is break in line. Pushing text to the next line, very rarely used.
  3. <sup> means superscript. It makes text elevated off the base line, for example, x2 (squared).
  4. <sub> means subscript. It makes text rendered below the base line, for example, for molecules H2O.

HTML Entities

HTML entitites start with & and finish with a ; They are special characters like roman numerals (Ⅰ), ampersand (&) signs or copyright (©) signs.

&amp; = &

Here is a full list of html entities.

Html semantics

Semantics are divs with meaningful names, they act exactly like a div, but the names give meaning to what they are such as, main, section, header, footer, article, nav. Read more about semantics here;

<aside>

<details>

<figcaption>

<figure>

<footer>

<header>

<main>

<mark>

<nav>

<section>

<summary>

<time>

Html tables

Tables: Tr, td & th elements

  1. <td> = Table data (table cell)
  2. <tr> = Table row
  3. <th> = Table header

Table header, footer & body

  1. <thead> = Table header
  2. <tbody> = Table body (main content)
  3. <tfoot> = Table footer (totals/sums etc)

Colspan & Rowspan

  1. colspan= "2" = An attribute to say how many columns the cell should span across
  2. rowspan= "2" = An attribute to say how many rows the cell should span across.

Table Example

Heaviest Birds

Animal Average Mass Flying Bird
Kg lbs
Ostrich 104 230 No
Somali Ostrich 90 200 No
Wild Turkey 13.5 28.8 Yes

<table>

<thead>

<tr>

<th rowspan= "2">Animal</th>

<th colspan= "2">Average Mass</th>

<th rowspan= "2">Flying Bird</th>

</tr>

<tr>

<th>Kg</th>

<th>lbs</th>

</thead>

<tbody>

<tr>

<td>Ostrich</td>

<td>104</td>

<td>230</td>

<td>No</td>

</tr>

<tr>

<td>Somali Ostrich</td>

<td>90</td>

<td>200</td>

<td>No</td>

</tr>

<tr>

<td>Wild Turkey</td>

<td>13.5</td>

<td>28.8</td>

<td>Yes</td>

</tr>

</tbody>

</table>

Html forms

When we submit a form, a HTTP request is sent, we can control where the form goes to with the action attribute. We can also control which type of HTTP method is used. (Get/Post)

Key attributes to mention

  1. Name is an attribute for inputs. It names the input data to send to the server, so name the input relevant to what the input it. This should go on every single input used.
  2. Value is an attribute for radio buttons. The value sends through what the value is selected to the server.

<form action="">

<div>

<label for= "username">Enter your username</label>

<input id= "username" type= "text" placeholder= "Username" name= "username">

</div>

<div>

<label for= "password">Enter your password</label>

<input id= "password" type= "password" placeholder= "Password" name= "password">

</div>

<button>Submit</button>

</form>

Hijacking Youtubes search

More inputs

Select a stock to buy;

Dropdowns

Range Sliders

Text Areas


Form validations (browser validations)

The following attributes are common browser validations;

  1. required Make the field required.
  2. min-length Add a minimum input length (great for passwords).
  3. maxlength Add a maximum input length (great for passwords).
  4. pattern Each validation follows a pattern, for example, email needs an @ symbol, with the pattern attribute, we can specify a pattern to follow for validation of specific fields.

SVGs

SVGs should be used instead of icon fonts as icon fonts has a lot of issues and can render black squares. Icon fonts are also not accessible to screen readers.

To use basic SVGs with sprite files;

Sprite files are svg files with all of the svg's in 1 file that is downloaded from a library. Sprite files are best practice to use as only 1 http request is needed instead of 1 for each svg.

<svg>
<use xlink:href="img/sprite.svg#icon-maginfying-glass"><use>
</svg>

The xlink:href attribute only works on web servers.

List of sources

    Colt Steeles web developer bootcamp 2021