@extends('template') @section('title') HTML/CSS Lab @stop @section('content') # HTML ## HTML: The code behind web pages - All web pages are structured using HTML code. - You can always see the HTML code by chosing View |Developer |View Source in the Chrome browser (or Ctrl+Click on the web page and choose View Page Source). - Hands-on learning of HTML with [W3 Schools website](http://www.w3schools.com/html/default.asp). **We strongly recommend this, especially if you have never worked with HTML before.** - [HTML Element reference](https://www.w3schools.com/TAgs/). ## Task 1a: Your first page Save the following code as `top5.html` in your `ps08` folder. ```html
The above code is a basic web page template. Note how it's divided into two main pieces (the screenshot
below doesn't refer to our file example):
1. The `head` where all **configuration** information about your page will go.
2. The `body` where the **content** of your page will go.
With your file set up, you're ready to start writing some HTML. With each edit you make below, save your changes and refresh the browser to see the results.
**Tip: Re-opening HTML files:** If you close your `top5.html` file in Canopy and try to re-open it, Canopy will display it as a web page, rather than showing you the HTML code.
To get around this, right click `top5.html` in the File Browser and choose `Open With > Code Editor`.
## Tag basics
HTML is a tag based language.
Tags are used to surround content, for example, here's a Heading 1 (`h1`) tag:
```
## Tag teamwork
Some tags work together with other tags.
For example, an `
(The artists in the above screenshot may not reflect the current top 5 artists you see when you build your page)
## Links
Some start tags have **attributes** to describe information about that element.
Example, the `` element ([anchors](https://www.w3schools.com/TAgs/tag_a.asp) i.e., links) has the `href` attribute which dictates where a link should go.
```
Ed Sheeran
```
### Task 1d: Add links
Edit your unordered list so that each artist name links to their artist page on Last.fm. For example, Ed Sheeran should link to `http://last.fm/music/Ed+Sheeran`.
Note that in order to accomplish this, you will be nesting `` elements inside of your existing `
```
The displayed image has a default width that may be too large for your tastes. You can change it using the `style` attribute to specify a different width:
```
```
The `alt` attribute is required for non-decorative images and is used to describe what the image is of. The alt attribute is important for search engines, and individuals who use screen readers:
```
```
### Task 1e: Add image
Right before the `
### Task 1f: Spotlight artist
Pick one of the top 5 artists (or any other artist you like) to spotlight on your page.
Below your unordered list, add a heading like:
```
```
_Side Note: Shrinking the image like this is not ideal, because while the image might display smaller, the browser still has to load the larger image, which will slow the loading of the page. When building real web pages that will be loaded on the internet, it's better to save the image and actually shrink it in a program like Photoshop. For our purposes, though, this technique is okay for now._
## Aside: Indentation in HTML
We've learned that correct indentation is essential in Python— if your code isn't properly indented, your script won't run.
HTML, however, is forgiving regarding spaces/indentation and your browser will ignore any white space in your code beyond a single space.
You can try it out: all of the following examples will produce the same results, despite their various spacing.
```
Wellesley
Wellesley