BAprog III yr 04-05-2020
HTML basics exercises
Sheet 1
Practice Questions with Solutions
1. Create a webpage that prints your name to the
screen.
2. Create a webpage that prints the numbers 1 - 10
to the screen.
3. Create a webpage and set its title to "This is a
webpage".
4. Create a webpage that prints the message "When
was this webpage created? Check page's title for
the answer." to the screen, and set the title of the
page to the current date.
5. Create a webpage that prints any text of your
choosing to the screen, do not include a head
section in the code.
6. Repeat exercise #5, but this time include a head
section in the code.
Solution 1
<html>
<body>
<!-- print name to the screen -->
John
</body>
</html>
Solution 2
<html>
<body>
<!-- print the numbers 1 to 10 to the screen -->
1 2 3 4 5 6 7 8 9 10
</body>
</html>
Solution 3
<html>
<head>
<!--set the title of the page-->
<title>This is a webpage</title>
</head>
<body>
<p class="note">
The title tag goes in the head section of an HTML
document.
</p>
</body>
</html>
Solution 4
<html>
<head>
<!--set the title of the page to the current date-->
<title>January 9th, 2009</title>
</head>
<body>
<!--print a message-->
When was this webpage created?
Check page's title for the answer.
</body>
</html>
Solution 5
<html>
<!--there is no head section in this HTML code-->
<body>
<!--print a message-->
The giraffe is a very interesting animal.
</body>
</html>
Solution 6
<html>
<head>
<title>Print some text</title>
</head>
<body>
<!--print a message-->
The giraffe is a very interesting animal.
</body>
</html>
HTML text exercises
(Try it yourself, solutions in the next pdf)
1. Print your name in green.
2. Print the numbers 1 - 10, each number being a
different color.
3. Prints your name in a Tahoma font.
4. Print a paragraph with 4 - 5 sentences. Each
sentence should be a different font.
5. Print a paragraph that is a description of a book,
include the title of the book as well as its author.
Names and titles should be underlined, adjectives
should be italicized and bolded.
6. Print your name to the screen with every letter
being a different heading size.