This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
tag at the end of each sentence. The
tag is different from the other tags we have worked with, as it does not require a closing tag. Use the
tag to enter blank lines. The
tag defines a paragraph.
Figure 6-6: The two sentences are on the same line and require more formatting.
Insert the
tag after “HTML is so easy.” The code now looks like this:
at the beginning of the sentence and a
at the end of the sentence. The code with a paragraph tag would look like this: HTML is so easyI will be teaching others HTML soon
tag
Once you have more text on your page, you can separate the text by using the header tags
I will be teaching others HTML soon
2. Save your page once you have made the changes. The <em> and tags are used to add emphasis to a certain word or sentence. In the next chapter, “CSS Basics,” you will see that we are able to apply much richer effects using style sheets. 3. Let’s add the <em> tags to the two sentences between the
tags so your code looks like this: <em>HTML is so easyI will be teaching others <em>HTML soon
4. Save your page once you have added the <em> tags and then view the page in your browser.) or a line break ( and
) after the line beginning with , or all of the text and images on your web page will be clumped together. Once you have added the new code, save the page and view it in your web browser.
98
Chapter 6 / HTML Basics
Figure 6-20: Blue link displayed under the image
4. You can easily link to another web site by adding the full address between the tags: FMWebschool Website You can also make the image into a hyperlink by using an tag and including a URL. Replace this line of code on your web page: FMWebschool Website with this code: 5. Save the page, and then view it in your browser. Figure 6-21: Image as a link
6. When you view the image on your web page, you will notice that a blue border surrounds it. The blue border lets visitors to your site know that the image is a clickable link. If you’d like, you can remove the blue border.
Chapter 6 / HTML Basics
99
To remove the blue border, simply add border="0" to your code: After adding the new code, save your page and view it in your web browser. The blue outline will be gone. 7. You have added links to text and to images, but you can also make a button a link using the form commands. To do this, place the outlined code shown in Figure 6-22 below the code you typed earlier. Be sure to add the
Figure 6-22: Code to make a button a link
Forms will be discussed more thoroughly later in this chapter and in Chapter 9.
Chapter 6
Figure 6-23: Clicking the button will open up http://www.fmwebschool.com in your browser window.
100
Chapter 6 / HTML Basics
Exercise 7 — Sending Emails with a Link You can also add an email link on your web site that will enable visitors to email you using their default email client. 1. Create a new page, and name it mail.html. Type the following code onto the new page and save it in your website folder:
Figure 6-24: Opening the default email client by clicking on a link
Chapter 6 / HTML Basics
101
3. You can also use an image as an email link. Make sure Envelope.gif is in your images folder. Then change the line of code that you just typed to: 4. Save this new code and then open the page with your web browser. You should now have an envelope image that opens your default email client when clicked.
Figure 6-25: Click the envelope to send an email.
.
Note: When you mouse over the envelope image, you will see the “mailto” address at the bottom of the web page. In Figure 6-25, it says “mailto:[email protected].” Note: When sending an email from your browser, your default email application will execute. Depending on your email client, your browser may display messages such as “another program is attempting to send an email.” There are ways to configure your email application so it will not display this message. See the “Sending Emails from the Web” section later in this chapter.
Chapter 6
.
102
Chapter 6 / HTML Basics
Exercise 8 — Anchors Aweigh! Anchors are used to connect text and images to a specific location on a page. For example, imagine a web site with dozens of paragraphs, each discussing a different animal. At the top of the page is an index of the animals. When you click on any of the animals in the index, you are automatically taken to the paragraph discussing that animal. This is done using anchors. 1. Create a new web page named anchors.htm, and save it in your website folder. You are about to do a lot of typing, so you may want to stretch your fingers. 2. Type the code shown in Figure 6-26, and save your page.
Figure 6-26: Header 2 links with anchors added
So far, you have added an
Lions can be ferocious if they so desire. I personally have never met a lion outside of a zoo, and I hope that I never have to meet one in the wild, considering I live in a very quiet neighborhood, and this would be most unusual. I’m not sure how you should react if you see a lion in your neighborhood. Do you stop, drop, and roll? You certainly cannot outrun a lion...and they can climb trees, right?
4. Once you have typed the above code, duplicate it four more times, and add it to the page. You can simply copy and paste each time. When you are finished, you should have five paragraphs. Save your page, as you still have a little more editing to perform. Tigers can be ferocious
n
Change the beginning of the third paragraph to read
Cheetahs can be ferocious
n
Change the beginning of the fourth paragraph to read
Lynxes can be ferocious
n
Change the beginning of the fifth paragraph to read
Sebastian can be ferocious
Chapter 6
5. You will notice that each paragraph begins with
Lions can be ferocious if they so desire. That is fine for the first paragraph, but we need to make changes to the other paragraphs so the anchors work correctly. tags to separate sentences, but we really don’t have a lot of control as to where the content will display on the page. This is where tables enter the picture. Tables provide a simple way to organize the content of your pages by enabling us to add alignment, background colors, borders, cell padding, cell spacing, and more. Tables are made up of horizontal rows and vertical columns. Each row and each column has a table cell. Tables consist of one or more rows of table cells. The
104
Chapter 6 / HTML Basics
6. Save the page once you have completed copying and pasting and making changes to the first line in the four paragraphs. Once you save your page, open it in your web browser and minimize it so that it is about half or one-third the size at which you would normally view the web page. When you click on one of the links at the top of the page, the page will scroll to the paragraph that is connected to that anchor. For instance, if you were to click on “Savage Sebastian,” the page will jump down to the paragraph with the anchor set to . You can see how this would be very useful if you had a page with numerous paragraphs. There is an example of the anchors.htm page in the Chapter 6 folder. You can also link an anchor to an image. The code is very simple: Take some time to review using anchors with both text and images.
Exercise 9 — Tables You may have noticed that the pages we are creating are not very structured. Yes, we are using
and