Take me to the top please!

← Back home

Learning HTML from scratch

Okay so before starting I had absolutely no idea about HTML. I'd only used it to change the font color in Obsidian using <font color="red">.

I was inspired to learn by some awesome Neocities websites.

I decided to grab a book from my local library called Curso de Desarrollo Web: HTML, CSS y JavaScript. Edición 2021. and get on with it. As I read along, I try out the tags the book explains and also recreate the examples.

Index

Here are my notes from each chapter of the book. They're not meant as a summary. I only take note of the stuff that is most interesting or surprising to me.

  1. Basic concepts
  2. Introduction to HTML
  3. Structure and main components of an HTML document
  4. Creating content
  5. Interactive web
  6. HTML5
  7. CSS Basics
  8. Selectors, inheritance, and cascade
  9. CSS Positioning
  10. CSS Configuration and appearance
  11. CSS3
  12. Flexbox CSS

2. Intro to HTML

Validating the code

It's important to validate our HTML code for 3 reasons:

Even if our code is not completly valid, most browsers will render it fine. The end user will not notice.

We can validate our code with this page from the World Wide Web Consortium (W3C). There's also a VS Code extension that I'm using that does the same thing.


3. Structure and main components of an HTML document

Structure

Attributes, links, and div

Trying out attributes here (check the code to see what I mean).
This is how you link to other websites

div is one of the most common tags. It is used to divide HTML documents into different sections and then apply CSS styles to them. The're identified with ids.

Text styles

Here is a list of styles presented as an unordered list (ul).

Using CSS Styles

We can apply styles to text directly in the HTML file.

Here's a neat example using color, font-size, and text-align.

We could also use a separate .css file called CSS style sheet. If we do that we have to link it to our HTML file using link in the header. But we'll do that later.

Some other cool stuff you can do

Hover over this text...

Create an example page as an exercise from the book

Tip: It is a good practice to add id attributes to all HTML tags. This will make it easier to add CSS styles to them later on.

Special characters


4. Creating content

Paragraphs

Paragraph on the right

Paragraph on the center

Paragraph on the left

Newlines don't show up on the rendered webpage if they're enclosed in <p> tags.

But we can force a line break
(like this)
using <br>.

Other tags

Anonymous author:
"My boyfriend isn't gay, he's simply a good person"

Tables!

Below I recreate the table in page 85 of the book:

And this is the caption :)
Header of this huuge table
Subheader
Period Concept Amount Discount
This month Call identification 12 € 0
Individual Line 14 € 0
City bonus 10 € 0
Total: 36 €
Footer of this huuge table

Lists

  1. Wow
  2. Such
  3. Order

A description list? That's obscure HTML for sure. Does anyone actually use these?

Term 1
Defninition of term 1
Term 2
Definition of term 2
Term 3
Definition of term 3

5. Interactive web

Forms

We create them with the <form> tag and have as attributes: action, method, accept, enctype, id. Here's an example.

Text boxes

Note: You should probably add an id to each field.

Enabled text box:

Disabled text box:

A tiny text box:

Sneaky text box:

Buttons

Regular button (need Javascript to make it do stuff):

File button:

Image button:

Reset button:

Submit button:

Options

Favorite color?

Blue
Orange
Pink
Yellow
Green

Accept terms and conditions?

Wait I haven't even read those how do I know if I agree or not (Yes)
No

Here! Check as many as you like as a reward!

Whohooo!
I
love
checkboxes <3

(List of) Lists of options

List of things you can to list options:

Text area

Hidden fields

(Check the code to see it)

Other things that aren't covered in the book

Note: Failure to select the correct option will result in ☠️ instant death ☠️

Select the number 37:    0 100

Select the number of siblings you have:

Select the color of a mirror:

Select your birthdate:

Write a phone number from French Guiana (assume you are calling from France and that it is a fixed phone line): Hint

Select the most appropiate time to slay thy enemies:

More input types!

Organizing forms

The form above is a terrible example of how a form should be organized. Here's a better example!

To organize a forms we use:

This page is getting quite long... Why don't we add a table of contents to make navigation easier? To do that, we have to:

  1. Add an id to the sections we want to link to (e.g. <h2 id="forms">)
  2. Add an anchor element with the # symbol followed by the section id (e.g. <a href="#forms">)

Like this:

Title

Another application of this is a ⬆️ Back to top button ⬆️.

Multimedia

Images

Remote image:

Square tiles at the Alhambra

Local image:

Dithered picture of Barcelona's Tram behind a tree.

Audio and video

We use the <object> tag to add audios and videos.With the <param> tag we control autoplay, looping, and so on.

If we want to use media from other web pages we should cite the webpage and also use the embed code they give you.

witnesstestimony by GamingWithJumbo | License: Creative Commons 0

(I embedded the audio because I am too lazy to download more files and also neocities doesn't let you upload audios and videos)


6. HTML5

Parts of an HTML document (semantic tags)

Diagram of semantic elements

Semantic tags help structure webpages by giving meaning to the elements of the HTML file. If your don't know which one to use just use a normal <div> tag. The most common elements are:

New form tags

The tiniest calculator in the world! + =

Multimedia

Mp3 and mp4 are the most compatible formats, you can't go wrong with those. You can also use .ogg, .wav, .webm etc. but they may not be compatible with some browsers.

Audio

Listen to this awesome music! Here, turn it on whenever you feel like!

Videos

Pretty much the same as audios but we can define width and height as well.


7. CSS Basics

Absolute and relative units

Absolute units: Not used as much, not very dynamic. Examples include cm, in, mm, pt (points = 0.35 mm), pc ("picas" = 4.23mm)

Relative units: Calculated from another reference element. Used more often. Examples include em (width of letter M), ex (height of letter X), px, %

Usually people use px for margins, fills, and layers and % or em for font sizes.

Comments

Add comments to your CSS code /* Like this */ to avoid hating yourself in the future.


8. Selectors, inheritance, and cascade

Example of a CSS rule and its parts

Selectors

First part of a CSS rule. It determines to which elements the rule is applied to. There are two main types:

Inheritance

By default HTML elements inherit the properties of the elements they're inside. But if there's a more specific rule that will be used instead.

Some properties are not inheritable. For instance, links have default colors in browsers. Even if we add a rule that makes all text orange, links will still be blue. To change this behavior we can add a {text-color: inherit;} to force inheritance.

Cascade

What if the same HTML element has conflicting rules? The most specific rule wins. In general ids are more specific than classes, and classes are more specific than regular HTML tags.

We can add !important to a declaration to block a property. This means no other CSS rule will override this property. For example, if we write p {color: black !important} all p elements will be black no matter what.


9. CSS Postitioning

🛑 Stop reading you nerd! Check out this demo page instead!🛑

Check out

Box model

Diagram of CSS box model

Every HTML element is represented as a box. Using CSS we can modify the margin, background-img, etc.

Some properties are shorthands that let us modify multiple properties at once. Examples include margin, border, etc.

Block elements vs Inline elements

Classification of HTML elements:

Positioning

The CSS property position can be:

Static, relative, absolute, and fixed positioning

(there's also inherit but it wasn't included in this awesome image)

Depending on the type, top, bottom, left, right have a different meaning:

Z-index

Use to define the "depth" of an element.

Higher z-index = closer to viewer (shows on top)

10. CSS Configuration and appearance

Text and paragrphs

According to this video your should not use px for fonts. Use rem instead, and em for margin, padding, etc.

Stuff you can change with CSS:

Links, images, and pseudoclasses

Dithered picture of a puddle
Figure 1: A dithered picture of a puddle

We can also change how things look only when we hover over them or click them. For instance:
Hover over me! This is a normal link
Now hover over me! This is a special link

We do this using pseudoclasses

Lists

Again, we can change pretty much everything when it comes to lists.

  1. Or
  2. the
  3. numbers

Because lists are so customizable, often people use them to make horizontal menus like this:


11. CSS3

Rounded borders

Wow so round
Even rounder!
You can change each corner individually too

Box-Shadows

Soft shadow
HARD SHADOW

Text in multiple columns

Lorem Ipsum

Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere.

Text overflow

I'm too lazy to do a demo of this. Just know that the relevnt properties are:

The difference between these properties is a bit confusing so just check out this article in case of doubt.

Buttons

We can customize buttons too!

(CSS adapted from Frutiger Aero Archive)

12. Flexbox CSS

Diagram of main flexbox components
Image credit: Girl Develop It NYC

Flexbox types

Flexbox notes

CONTAINER PROPERTIES

ITEM PROPERTIES

You know what? I'm done now. Instead of reading this book I'm going to link to some resources I found to learn how flexbox works:

wrapper
Box 1
Box 2
Box 3
Box 4
Box 5
Box 6
Box 7
Box 8