By the end of today, you should be able to…
- Recognize the most common HTML tags and their standard formatting
- Make a static web page using HTML
- Create a form to collect user data using HTML
- Use a browser’s developer tools to examine and change the HTML of a website
Write a list of every HTML element you know, and its purpose. Write as many as you can!
- E.g.
head
,body
,img
, etc
- HyperText Markup Language
- Not a programming language! No loops, conditionals, etc
- Tells your browser how to structure content (text, images, links, etc)
The fundamental building block of HTML is an element.
- Can have an opening and closing tag
- Or only a single tag
Tags are enclosed in angle brackets ( <
and >
)
At the top of every HTML page, we need to tell the browser what type of markup to expect.
<!DOCTYPE html>
- The doctype tag is technically not an element.
All page content must go inside of the html
start/close tags.
<!DOCTYPE html>
<html>
</html>
Content that doesn't directly relate to the way the page is laid out - including the styles and title - go inside of the head
element.
<!DOCTYPE html>
<html>
<head>
<title>My Awesome Page Title</title>
</head>
</html>
The body contains all of the elements that will be displayed on the page itself.
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
This will appear on the page.
</body>
</html>
Let's put it all together! Save the code snippet below and open it in your browser.
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
Hello, World!
</body>
</html>
Headers are used to set apart page, section, etc. headers.
h1
is a top level heading. We can use h1
to h6
for different sized headers.
<body>
<h1>Why Dogs are Cool</h1>
<p>Dogs are cool because...</p>
</body>
The paragraph tag <p>
is used to indicate a paragraph of text.
<body>
<h1>Why Dogs are Cool</h1>
<p>Dogs are cool because...</p>
</body>
The address, or <a>
tag, links to another web page.
href
is an attribute that indicates the destination.
<a href="http://www.aspca.org">Adopt a Dog!</a>
The img
element is a self-closing tag. We often end it with /
to indicate such.
- Images must also have an alt attribute which describes the image in text.
<img src="http://makeschool.com/images/dog" alt="cute dog" />
We can add a line break like so:
<br />
We can specify that text should be bold with the strong
tag, or italic with the em
(emphasize) tag.
<p>
Dogs are <strong>fluffy</strong> and <em>playful</em>.
</p>
We can make a bulleted unordered list with the ul
tag, and add list items with the li
tag.
<p>
I like dogs because they are...
<ul>
<li>fluffy</li>
<li>playful</li>
</ul>
</p>
We can also make an ordered list, starting from 1, with the ol
tag.
<p>
My favorite dogs (in order) are:
<ol>
<li>Husky</li>
<li>Chocolate Lab</li>
<li>Shiba Inu</li>
<li>Golden Doodle</li>
</ol>
</p>
- Collect data about the user
- Ask the user a question
- Login or registration forms
<form action='/results' method='GET'>
What is your name?
<input type='text' name='firstname'>
<br>
<input type='submit' value='Submit!'>
</form>
Form attributes:
action
: What URL am I sent to when I submit the form?method
: Is it a GET or a POST request?
<form action='/results' method='GET'>
Form element attributes:
type
: What type of data am I collecting (e.g. number vs. text), and in what format?name
: What label am I putting on the data? Hint: This is kind of like a variable name!value
: What is the default value of the form element?
<input type='text' name='favorite_color' value='blue'>
Get into groups of 4 or 5 and research a specific form element. Within your group, do the following:
- Test out the form element in your browser. How does it work?
- What attributes (such as
name
,value
, etc) are required to use this form element? What do they do? - What query string results when you submit the form?
Every person in the group must be able to present the findings!
Form expert groups around your table. Fill in the rest of your worksheet for at least four input elements.
- Homework 1: Due Monday, Oct. 28