Lab 6. HTML Tags Examples - PART I
Lab 6. HTML Tags Examples - PART I
Lab 6. HTML Tags Examples - PART I
CMPE109 - LAB 6
1. Getting Started:
Be careful! After changing the extension, the icon will be changed like shown (an explorer or
chrome icon). If the icon is still Wordpad, then you should do the following:
Open a folder- Choose View Tab- Click Options- Change folder and search options
Folder Options- Choose View - Remove the tick for “Hide the extension for the known file types”
After making this setting, you will observe that your file is now: namesurname.html.txt
Then, delete .txt extension.
1
CMPE109- Fundamentals of Computing Lab6 2019-2020 FALL
2. HTML Tags
The basic structure of an HTML document includes tags, which surround content and apply meaning to
it.
<!DOCTYPE html>
<html>
<body>
This is my first web page
</body>
</html>
The first line on the top, <!DOCTYPE html>, is a document type declaration is used to inform a website
visitor's browser that the document being rendered is an HTML document.
To get back to the point, <html> is the opening tag that kicks things off and tells the browser that
everything between that and the </html> closing tag is an HTML document.
The stuff between <body> and </body> is the main content of the document that will appear in the
browser window.
3. Page Titles
To add a title to your page, change your code so that it looks like this:
<!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
</head>
<body>
This is my first web page
</body>
</html>
• The head element (that which starts with the <head> opening tag and ends with the </head>
closing tag) appears before the body element (starting with <body> and ending with </body>)
and contains information about the page.
• The information in the head element does not appear in the browser window.
2
CMPE109- Fundamentals of Computing Lab6 2019-2020 FALL
4. Paragraph
<!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
</head>
<body>
<p>This is my first web page</p>
<p>How exciting</p>
</body>
</html>
If <p> tag is used, the two lines will now appear on two lines because the browser recognizes them as
separate paragraphs.
5. Line breaks: The line-break tag <br> can also be used to separate lines like this:
<!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
</head>
<body>
This is my first web page<br>
How exciting
</body>
</html>
Note: There’s no content involved in breaking lines so there is no closing tag for <br>.
6. Headings
The defined headings are h1, h2, h3, h4, h5 and h6.
3
CMPE109- Fundamentals of Computing Lab6 2019-2020 FALL
<!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
</head>
<body>
<h1> This is my first web page </h1>
<h2> This is my first web page </h2>
<h3> This is my first web page </h3>
<h4> This is my first web page </h4>
<h5> This is my first web page </h5>
<h6> This is my first web page </h6>
</body>
</html>
You can emphasize text in a paragraph using em (emphasis) and strong (strong importance).
<!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
</head>
<body>
<p>Yes, that really <em>is</em> exciting. <strong>Warning:</strong>level of excitement increasing!
</p>
</body>
</html>
You can use <i> and <b> tags for italic and bold.
4
CMPE109- Fundamentals of Computing Lab6 2019-2020 FALL
<html>
<head>
<title>My first web page</title>
</head>
<body>
<p><b><font color="red">Sports I like:</font></b>
<p><i>Tennis</i>
<p><i>Basketball</i>
</body>
</html>
Note: Instead of writing a color like “red”, “blue”, etc. you can use the HTML Color Codes (hexadecimal
color codes). Check the website below. Use color picker menu to select a color.
https://htmlcolorcodes.com/
Change the font color of the previous example and observe the changes:
5
CMPE109- Fundamentals of Computing Lab6 2019-2020 FALL
8. Alignment of a text
The align attribute specifies the alignment of the text within a paragraph.
A centered paragraph:
<!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
</head>
<body>
<p>This is a paragraph.</p>
<p align="center">This is a centered text in a paragraph.</p>
<p align="right">This is a right-aligned text in a paragraph.</p>
</body>
</html>
References: