{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# HTML and CSS\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Markup Languages\n", "Essentially, a markup language is a type of language that employs annotations or tags to dictate how a computer should process the text within those tags. The tags provide the computer with instructions on how to display or interpret the enclosed text. Many markup languages are designed to be easily readable by humans and are intended to be composed using simple text editors, not complex word processors such as MS Word. The present book employs a markup language known as Markdown. Markdown prioritizes human readability and simplicity.\n", "\n", "\n", "## HTML (Hyper-Text Markup Language)\n", "HTML, similar to other markup languages, aims to structure a document and provide content. Styling and aesthetics come later, with the introduction of CSS.\n", "\n", "In HTML, tags are used to markup the document. They follow the format for opening and for closing, with the forward slash differentiating the closing tag from the opening tag.\n", "\n", "An HTML document is essentially a sequence of these paired tags. Let's take a look at a rudimentary HTML document:\n", "\n", "```\n", "\n", " \n", " Sample Page\n", " \n", " \n", "

My First Heading

\n", "

A straightforward paragraph of text.

\n", "

Another paragraph of text.

\n", " \n", "\n", "```\n", "\n", "In this example, if you were to adjust the text within one of the paragraphs, or perhaps change the h1 tag to h2 (remember to adjust both opening and closing tags), you'll see the changes reflected when viewing in a browser.\n", "\n", "Indentation is used for clarity and does not affect how the browser interprets the HTML document. You could remove all indentation or place all code on one line, and the rendered page would remain unchanged.\n", "\n", "As we delve into specific HTML tags, it's beneficial to contemplate the overall structure of the webpage being built. One way to visualize this is through a \"tree view\" of the HTML page. In such a view, the html tag is the root of the tree, branching out to head and body tags as its children, which further subdivide into other tags. The tree view illustrates the hierarchical nature of an HTML document, a structure we'll frequently revisit as we begin working with CSS and JavaScript.\n", "\n", "\n", "## HTML Document Structure\n", "Imagine an HTML document as a neatly organized office file. It has a clear structure, with different sections serving different purposes. Here's how it looks:\n", "```\n", " html\n", " Copy code\n", " \n", " \n", " \n", " Page Title\n", " \n", " \n", "

My First Heading

\n", "

My first paragraph.

\n", " \n", " \n", "```\n", "The declaration is like the label on the file - it tells the browser that this is an HTML5 document. The tag is the file itself, containing all the other elements. The is like the file's index, containing meta-information about the document, while the is the main content of the file.\n", "\n", "## Basic HTML Tags\n", "Now, let's explore the basic elements or 'tags' that make up the content of a web page.\n", "\n", "* Headings: Headings in HTML are like the chapter titles in a book, guiding the reader through the content. They range from `

` for main headings, down to `

` for the smallest subheadings.\n", "* Paragraphs: The `

` tag is used to define a paragraph. It's like the sentences in a book, providing the main content.\n", "* Images: Images bring a web page to life! The `` tag is used to embed an image in a web page. Remember to always include the alt attribute to provide a description of the image for screen readers.\n", "* Links: Links are the essence of the web, connecting one page to another. The `` tag defines a hyperlink.\n", "* Text Formatting: HTML provides several tags for formatting text, including `` for bold text, `` for italic text, and `` for underlined text.\n", "\n", "## Advanced HTML Tags\n", "As we delve deeper into HTML, we encounter more complex tags that allow us to create a variety of content structures.\n", "\n", "* Unordered lists, created with the `