HTML Short Intro
HTML Short Intro
</strong>
In the editor to the right, there's a tab called test.html. This is the file we'll type our HTML into. See the code with the <>s? That's HTML! Like any language, it has its own special syntax(rules for communicating).
When we press Save & Submit Code, the results tab will act like an Internet browser (e.g. Chrome, Firefox, Internet Explorer). A browser's job is to transform the code in test.html into a recognizable webpage! It knows how to lay out the page by following the HTML syntax.
Instructions
1. 2. 3.
To the right, we have a test.htmlfile. Change the text on line 2 (the bit between <strong> and </strong>) to anything you like! Hit Save & Submit Code, and you'll see how the test.html file would look in a browser. Did you see that? The<strong></strong> tags made our text bold!
Instructions
1. 2.
Go ahead and put the three lines mentioned above into test.html, which is now blank. In between the second and last line (between the <html> and the </html>), feel free to write whatever message you like.
Basic terminology
To learn more HTML, we should learn how to talk about HTML. Already you have seen we use <>s a lot. 1. 2. 3. 4. Things inside <>s are called tags. Tags nearly always come in pairs: an opening tag and a closing tag. Example of opening tag: <html> Example of closing tag: </html> You can think of tags as being like parentheses: whenever you open one, you should close it. Tags also nest, so you should close them in the right order: the most recently opened tag should be the first one closed, like in the example below.
<first tag><second tag>Some text!</second tag></first tag>
The last exercise taught us how to set up our HTML file. Everything we do now will go between <html> and</html>. Practice makes perfect! One more time:
Instructions
1. 2. 3. 4.
Put in the <!DOCTYPE HTML> tag. Put in the <html> opening and closing tags. Between the <html> tags, write whatever you like. Press Save & Submit Code to see what you've written appear on the page!
<!DOCTYPE html> <html> <head> This is the header <title> My title page </title> </head> </html>
Instructions
Let's add a head and a title to our webpage. If you get stuck at any point, click "Stuck? Get a hint!" below for an example. 1. 2. 3. 4. Add an opening <head> tag and closing </head> tag. Between the <head> tags, add in an opening <title> tag and closing</title> tag. Between the <title> tags, write in a title for your page. For example, "My Webpage." Press "Save & Submit Code" to continue
<!DOCTYPE html> <html> <head> <title>My title page</title> </head> <body> <p>1</p> <p>Hi everybody</p> </body> </html>
Instructions
1.
Underneath the closing </head>tag, put an opening <body> tag and a closing </body> tag, like in the example above.
2.
Inside the body, create two paragraphs. Each paragraph starts with an opening <p> tag and ends with a closing </p> tag. We can write content in between the tags, like this:
<body> <p>Hello world!</p> </body>
<!DOCTYPE html> <html> <head> <title> Headings & Paragraphs </title> </head> <body> <h1>Header 1</h1> <p>Paragraph1</p> <p>Paragraph2</p> </body> </html>
Instructions
1. 2. 3. 4.
In the body section, create a heading. To do this, create an <h1> tag. Add content. Close the element with a closing tag</h1>. (Your content should now be between <h1> and </h1>.) Underneath the heading tags, create two paragraphs using <p> tags with whatever content you like.
<!DOCTYPE html> <html> <head> <title> Headings & Paragraphs </title> </head> <body> <h1>Header 1</h1> <p>Paragraph1</p> <h3>Header 3</h3> <p>Paragraph2</p> <h5>Header 5</h5> <p>Paragraph3</p> </body> </html>
<h1> - The CEO <h2> - VP <h3> - Director <h4> - Middle management <h5> - Lowly assistant <h6> - Gets coffee for everyone
Below we'll ask you to add headings of various sizes. Feel free to write whatever you like for the headings!
Instructions
1. 2. 3.
Your code currently has one <h1>heading and two paragraphs. Add an <h3> heading before the second paragraph. Add an <h5> heading after the second paragraph, and then add a third paragraph after this heading.
<!DOCTYPE html> <html> <head> <title> Headings & Paragraphs </title> </head> <body> <h1>Header 1</h1> <p>Paragraph1</p> <h2>Header 2</h2> <p>Paragraph2</p> <h3>Header 3</h3> <p>Paragraph3</p> <h4>Header 4</h4> <p>Paragraph4</p> <h5>Header 5</h5> <p>Paragraph5</p> <h6>Header 6</h6> <p>Paragraph6</p> </body> </html>
Instructions
1.
Add three more headings to the code, making use of <h2>, <h4> and<h6>. Make sure to close all your tags!
2.
Under each heading, add a short paragraph. Dont forget paragraphs need opening and closing <p></p>tags!
Mid-lesson breather
You've done an awesome job! Here's a quick summary of things we've learned: 1. 2. 3. 4. HTML is used to give websites structure. We open HTML files using a browser, and the browser renders(shows us) the file. HTML files have a <head> and a<body> (just like you!) In the head, we have the <title>tags, and we use these to specify the webpage's name.
5.
Instructions
1. 2.
Add a title between the <title>tags. Create a <h3> sized heading in the body. Make your heading say anything you want! (Just don't forget to close it.)
3.
Create three paragraphs using <p>tags and fill them with content (e.g.about cars, your pet, favorite city to travelwhatever you like!)
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <a href="http://www.codecademy.com">My Favorite Site! </body> </html> </a>
1.
First, there's an opening <a> tag and that tag has an attribute called href. The href value tells your link where you want it to go, in this case http://www.codecademy.com.
2.
Then you have a description of your link between your opening <a> and your closing </a> tags. This is what you will be able to click on.
3.
Instructions
1.
In the body section, create a link. To do this, create an <a> tag. Point your link to a website by setting the value of the href attribute
2. 3.
Add a description of your link Close the element with a closing tag</a>
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <img src="http://s3.amazonaws.com/codecademy-blog/assets/f3a16fb6.jpg" />
Adding images
You can add images to your websites to make them look fancy. We use an image tag, like so: <img>. This tag is a bit different from the others. Instead of putting the content between the tags, you tell the tag where to get the picture using src. It's also different because there is no ending tag. It has / in the tag to close it: <img src="url" />. Check out the tag to the rightit adds a picture of a rubber duck to the page! (You can see it by clicking on the Preview button.) See the web address (or URL) aftersrc=? It's"http://s3.amazonaws.com/codecademyblog/assets/f3a16fb6.jpg". That tells the <img> tag where to get the picture from!
Every image on the web has its own image URL. Simply right-click on an image and choose "Copy image URL." Paste that URL in quotes after src= to insert with your <img> tag.
Instructions
Add a second image below the first one. (Make sure it's before the closing <body> tag!) If you can't think of a good picture, use this ninja:
http://s3.amazonaws.com/codecademy-blog/assets/ninja_zpsa5dbe37a.jpg
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <a href="http://www.codecademy.com"> <img src="http://s3.amazonaws.com/codecademy-blog/assets/f3a16fb6.jpg" /> AAAA AAAAA AAAA</a> <img src="http://s3.amazonaws.com/codecademy-blog/assets/ninja_zpsa5dbe37a.jpg" /> </body> </html>
1. 2. 3.
First we open our <a> tag and point the href tohttp://www.codecademy.com/ again. But this time, instead of using text inside the <a> tag, we use an <img>tag. Finally, we have our closing </a>tag. Now when you click on the yellow duck, you will be taken tohttp://www.codecademy.com! Placing one HTML tag inside of another is called nesting.
Instructions
1. 2. 3.
In the body section, create an <a>tag. Choose a website to point your link to, like <ahref="http://www.codecademy.com">. Now create your <img> tag between your opening <a> tag and closing </a> tag. Don't forget the src!
4.
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <a href="http://www.codecademy.com"> <img src="http://s3.amazonaws.com/codecademy-blog/assets/f3a16fb6.jpg" /> AAAA AAAAA AAAA</a> <img src="http://s3.amazonaws.com/codecademy-blog/assets/f3a16fb6.jpg" /> <a href="http://www.codecademy.com">AAA</a>
</body> </html>
Instructions
1.
Between the <body> tags, add two images using the <img> tag. One should be a link; the other should not. The link can go anywhere you want.
2.
After your two images, create a link that's just a line of text. It can link anywhere you want.
Instructions
Your webpage is blank as the day it was born! Let's add five things: 1. 2. 3. 4. 5. The <!DOCTYPE> tag Your <html> tags Your <head> tags
<title> tags (with any title you like!) between your head tags
Instructions
Create an <h1> tag inside your body tags. Between your opening <h1> and closing </h1> tags, type your name for all to see!
<!DOCTYPE HTML> <html> <head> <title></title> </head> <body> <h1>Header 1</h1> <p>Paragraph 1</p> <p>Paragraph 2</p> <p>Paragraph 3</p> </body> </html>
Instructions
Insert three <p> tags after your <h1>tag (but before your closing </body>tag!). Write a little bit about yourself in each of the three paragraphs. You can say whatever you want! It's your webpage.
<!DOCTYPE HTML> <html> <head> <title></title> </head> <body> <h1>Header 1</h1> <img src="http://bit.ly/RhrMEn" /> <p>Paragraph 1</p>
Instructions
Insert an <img> tag between your<body> tags. Feel free to put it anywhere! (We think it'd look best after your <h1> tag, but before your <p>tags.) You can make the src attribute point to any image you like.
<!DOCTYPE HTML> <html> <head> <title></title> </head> <body> <h1>Header 1</h1> <a href="2"><img src="http://bit.ly/RhrMEn" /></a> <p>Paragraph 1</p> <p>Paragraph <a href="2">2</a></p> <p>Paragraph 3</p> </body> </html>
Link me!
Great! There's only one problem: your webpage is like a house with no doors. There's no way to get in or out! We'll fix that by adding a couple of links. Once you successfully add your links and hit Run, you've finished! Revel in the glory of your newly created webpage. If it still looks a little basic to you, don't worry. We'll soon teach you CSS to make your webpages look sharp!
Instructions
Add at least two links to your webpage. You can turn an image or a bit of text into a link; you can even turn part of the text inside your <p> tags into a link! Check out the Hint if you've forgotten how the <a> tag works.
HTML Basics II