Intro to:
<tag>Content</tag>
<pizza>
<topping>pineapple</topping>
<topping>ham</topping>
<topping>cheese</topping>
</pizza>
<tag attribute="value">Content goes here</tag>
<img src="path/to/image/file.jpg" alt="description" />
attribute
value
attribute
value
<h1>This is a Heading</h1>
opening tag
closing tag
self closing
<!DOCTYPE html>
<html>
<head>
<title>Page title goes here</title>
</head>
<body>
Content goes here!
</body>
</html>
* No spaces and all lowercase.
Dashes or underscores are OK.
tts/html/my_first_site
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.
<!DOCTYPE html>
<html>
<head>
<title>My first awesome web page</title>
</head>
<body>
<h1>Jaime's Page</h1>
<p>A simple page put together using HTML!</p>
</body>
</html>
Save as: my_first_page.html
* No spaces and all lowercase. Dashes or underscores are OK.
Open up Sublime and let's play around with some HTML.
Copy your my_first_page.html and save it as travel.html
Let's format some text on our page with heading tags.
<h1> through <h6> (1 being the highest level, 6 being the lowest). Headings should be used in order and h1 only once.
<h1>Welcome to Travel Bug</h1>
<h2>Places I'd Like to Visit</h2>
Paragraphs or <p> simply separate lines of text into paragraphs. They typically sit below headings.
Adding <b> or <strong> will embolden the text.
Adding <i> or <em> will italicize the text.
<h1>Welcome to Travel Bug</h1>
<p>This is a site dedicated to all the cool places I'd like to visit.</p>
<p>If anyone wants to invite me on a trip <em>please</em> email me!</p>
<h2>Places I'd Like to Visit</h2>
<p>Here are some destinations I've been <b>dreaming</b> about.</p>
HTML gives us 2 types of lists. Ordered (numbered) and unordered (bulleted) lists.
Nested list items, or <li> sit inside <ol> or <ul> tags.
<h2>Places I'd Like to Visit</h2>
<p>Here are some destinations I've been dreaming about.</p>
<ul>
<li>New Zealand</li>
<li>Peru</li>
<li>South Africa</li>
<li>Belize</li>
</ul>
Open a new file in Sublime and save it as eats.html
Create a basic html page with a heading, paragraph and list 5 of your favorite restaurants.
Open your page in Chrome and holler!
<!DOCTYPE html>
<html>
<head>
<title>Jaime's Favorite Restaurants</title>
</head>
<body>
<h1>Good Eats</h1>
<p>Here are a few of my favorite places to eat in Atlanta.</p>
<ol>
<li>2 Urban Licks</li>
<li>Victory Sandwich</li>
<li>JCT Kitchen</li>
<li>Bar Taco</li>
<li>Antico Pizza</li>
</ol>
</body>
</html>
Linking (or hyperlinking) lets us navigate through the pages in our site and elsewhere. No Javascript necessary!
An anchor tag <a> is used to define a link. You also need to add a parameter (href) to set the destination of the link.
Lets add an external link to one of our list items.
<ul>
<li><a href="http://www.newzealand.com/">New Zealand</a></li>
<li>Peru</li>
<li>South Africa</li>
<li>Belize</li>
</ul>
Clicking this link directs us to another site which is great. But anyone notice the problem? We're losing our audience because the new site opens in the same window.
Let's tack on another parameter so a new tab opens instead and our site stays put!
<a href="http://www.newzealand.com/" target="_blank">New Zealand</a>
How would we link to another page in our own site? Well, we have to add pages first!
Let's add a new page and name it after one of our list items. I called mine belize.html.
<!DOCTYPE html>
<html>
<head>
<title>Belize</title>
</head>
<body>
<h1>Page about Belize</h1>
<p>Simple paragraph about Belize.</p>
</body>
</html>
Meanwhile, back on travel.html we'll add our internal link. Since it's in the same folder we can simply set "belize.html" as our destination.
And just like that our pages are linked together.
<ul>
<li><a href="http://www.newzealand.com/">New Zealand</a></li>
<li>Peru</li>
<li>South Africa</li>
<li><a href="belize.html">Belize</a></li>
</ul>
How would we link back to travel.html from our Belize page?
<h1>Page about Belize</h1>
<p>Simple paragraph about Belize.</p>
<a href="travel.html">Back to travel</a>
Let's spice up this boring, text-heavy page with images!
Select an image you dig, then click View Image from the right side menu.
Then select and copy the link from the address bar.
We use the <img> tag with a "src" (short for source) parameter to put an image on our page. Paste your image URL into the value.
<img src="http://www.hahanz.com/images/31.jpg" width="700" alt="New Zealand">
We should also add a width parameter to control sizing, and an alt tag to provide a text description of our image.
NOTE: Adding a width will automagically calculate the height for us. Try experimenting with percentages too.
What are some possible problems with linking to images externally?
Someone may take down the website or move the image. A better approach is to save the image to a folder inside our site. This way we have control over it!
Go ahead and create a folder called "assets" and inside there a folder called "images."
Select another medium sized image but instead of copying the URL let's save it to our images folder.
You should name the image something meaningful and short. Don't include spaces and keep it lowercase.
To add an image saved locally we'll use the same syntax as before. This time, though, we point to the image's location in the assets/images folder.
<img src="assets/images/new_zealand.jpg" width="700" alt="New Zealand">
If the image doesn't show up reexamine your folder structure. Make sure your image folder is nested inside your assets folder. Inside that, the image should be a .gif, .jpg or .png file and consist of all lowercase letters.
Try adding another local image to travel.html
<p style="color:red;">This is my snazzy red paragraph!</p>
<p>This paragraph will not be red.</p>
h1 { color: gray; }
selector
{ declaration block }
property
value
* Internal and external stylesheets
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
font-size:50px;
text-align: center;
}
</style>
</head>
<body>
<h1>Welcome to Travel Bug</h1>
<p>Supporting paragraph. Very informative.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="assets/stylesheets/styles.css">
</head>
<body>
<p>This is my snazzy red paragraph!</p>
</body>
</html>
body {
width: 900px;
margin: auto;
}
p {
color: violet;
text-align: center;
}
HTML
CSS
p {
color: violet;
text-align: center;
}
<p>
Something Awesome!
</p>
#top {
background:gray;
text-align:center;
}
<div id="top">
Something Awesome!
</div>
.blue-text {
color: blue;
font-size: 15px;
}
<p class="blue-text">
Something Awesome!
</p>
<p class="blue-text">
Something else awesome!
</p>
Save a new stylesheet as eats-styles.css
Change the color of your unordered list of 5 restaurants with an element selector.
Change your favorite to a different color with a class selector.
Share with the class!
<!DOCTYPE html>
<html>
<head>
<title>My favorite restaurants</title>
<link rel="stylesheet" href="assets/stylesheets/eats-styles.css">
</head>
<body>
<ul>
<li>2 Urban Licks</li>
<li>Victory Sandwich</li>
<li>JCT Kitchen</li>
<li>Bar Taco</li>
<li class="fave">Antico</li>
</ul>
</body>
</html>
li {
color: blue;
}
.fave{
color: red;
}
HTML
list.html
CSS
list-styles.css
Most developers use Chrome because it comes pre-installed with a set of developer tools that make debugging and troubleshooting easier.
Create a 2 page personal website
index.html
about_me.html