Q3 MODULE2 G10 PROGRAMMING MANGALDAN-NHS-Final
Q3 MODULE2 G10 PROGRAMMING MANGALDAN-NHS-Final
10
TLE- ICT
COMPUTER PROGRAMMING
QUARTER 3 – MODULE 2
HTML - CUSTOMIZING FONT STYLE
Prepared by:
EUGENIO L. MOLINA
Teacher III
Mangaldan National High School
QUARTER III
WEEK II
I. LEARNING OBJECTIVES
After reading this module you will be able to apply the different ways on how to change
the color of the text in HTML and customize the font style.
II. INTRODUCTION
In this module we will see various ways of applying styles to an HTML document such
as adding color to the document. Seeing color as a major part of any website design, let us
look more closely at applying color to a web page. Fonts also play a very important role in
making a website more user friendly and increase content readability. Font face and color
depends entirely on the computer and browser that is being used to view your page but you
can use HTML <font> tag to add style, size, and color to the text on your website.
III. READINGS/LECTURES
HTML – Colors
Colors are very important to give a good look and feel to your website. You can specify
colors on page level using <body> tag or you can set colors for individual tags
using bgcolor attribute.
The <body> tag has the following attributes which can be used to set different colors:
• bgcolor − sets a color for the background of the page.
• text − sets a color for the body text.
• alink − sets a color for active links or selected links.
• link − sets a color for linked text.
• vlink − sets a color for visited links − that is, for linked text that you have already
clicked on.
1
• Color decimal or percentage values − This value is specified using the rgb( )
property.
Now we will see these coloring schemes one by one.
You can specify direct a color name to set text or background color. Here is the list of
standard 16 colors names and it is recommended to use them.
Example
Here is an example on how to set background of an HTML tag by color name.
<!DOCTYPE html>
<html>
<head>
<title>HTML Colors by Name</title>
</head>
</html>
2
Paintshop Pro or MS Paint. Each hexadecimal code will be preceded by a pound or hash
sign #. Here is a list of few colors using hexadecimal notation.
#000000
#FF0000
#00FF00
#0000FF
#FFFF00
#00FFFF
#FF00FF
#C0C0C0
#FFFFFF
Example
Here are the examples to set background by color code in hexadecimal −
<!DOCTYPE html>
<html>
<head>
<title>HTML Colors by Hex</title>
</head>
</html>
3
This color value is specified using the rgb( ) property. This property takes three
values, one each for red, green, and blue. The value can be an integer between 0 and 255
or a percentage.
rgb(0,0,0)
rgb(255,0,0)
rgb(0,255,0)
rgb(0,0,255)
rgb(255,255,0)
rgb(0,255,255)
rgb(255,0,255)
rgb(192,192,192)
Example
Here are the examples to set background of an HTML tag by color code using rgb()
values −
<!DOCTYPE html>
<html>
<head>
<title>HTML Colors by RGB code</title>
</head>
<body text = "rgb(0,0,255)" bgcolor = "rgb(0,255,0)">
<p>Font using RGB.</p>
<table bgcolor = "rgb(0,0,0)">
<tr>
<td>
<font color = "rgb(255,255,255)">This text will appear white on black
background.</font>
</td>
4
</tr>
</table>
</body>
</html>
HTML - Fonts
The font tag has three attributes called size, color, and face to customize your fonts.
To change any of the font attributes at any time within your webpage, simply use the <font>
tag. The text that follows will remain unchanged until you close with the </font> tag. You can
change one or all of the font attributes within one <font> tag.
Note −The font and basefont tags are deprecated and it is supposed to be removed in a
future version of HTML. So they should not be used rather, it is suggested to use CSS styles
to manipulate your fonts.
You can set content font size using size attribute. The range of accepted values is
from 1(smallest) to 7(largest). The default size of a font is 3.
Example
<!DOCTYPE html>
<html>
<head>
<title>Setting Font Size</title>
</head>
<body>
<font size = "1">Font size = "1"</font><br />
<font size = "2">Font size = "2"</font><br />
<font size = "3">Font size = "3"</font><br />
<font size = "4">Font size = "4"</font><br />
<font size = "5">Font size = "5"</font><br />
<font size = "6">Font size = "6"</font><br />
<font size = "7">Font size = "7"</font>
</body>
</html>
5
Font size = "6"
Font size = "7"
Relative Font Size
You can specify how many sizes larger or how many sizes smaller than the preset font size
should be. You can specify it like <font size = "+n"> or <font size = "−n">
Example
<!DOCTYPE html>
<html>
<head>
<title>Relative Font Size</title>
</head>
<body>
<font size = "-1">Font size = "-1"</font><br />
<font size = "+1">Font size = "+1"</font><br />
<font size = "+2">Font size = "+2"</font><br />
<font size = "+3">Font size = "+3"</font><br />
<font size = "+4">Font size = "+4"</font>
</body>
</html>
Example
<!DOCTYPE html>
<html>
6
<head>
<title>Font Face</title>
</head>
<body>
<font face = "Times New Roman" size = "5">Times New Roman</font><br />
<font face = "Verdana" size = "5">Verdana</font><br />
<font face = "Comic sans MS" size =" 5">Comic Sans MS</font><br />
<font face = "WildWest" size = "5">WildWest</font><br />
<font face = "Bedrock" size = "5">Bedrock</font><br />
</body>
</html>
A visitor will only be able to see your font if they have that font installed on their
computer. So, it is possible to specify two or more font face alternatives by listing the font
face names, separated by a comma.
When your page is loaded, their browser will display the first font face available. If
none of the given fonts are installed, then it will display the default font face Times New
Roman.
You can set any font color you like using color attribute. You can specify the color that
you want by either the color name or hexadecimal code for that color.
Example
<!DOCTYPE html>
<html>
<head>
7
<title>Setting Font Color</title>
</head>
<body>
<font color = "#FF00FF">This text is in pink</font><br />
<font color = "red">This text is red</font>
</body>
</html>
The <basefont> element is supposed to set a default font size, color, and typeface for
any parts of the document that are not otherwise contained within a <font> tag. You can use
the <font> elements to override the <basefont> settings.
The <basefont> tag also takes color, size and face attributes and it will support relative
font setting by giving size a value of +1 for a size larger or −2 for two sizes smaller.
Example
<!DOCTYPE html>
<html>
<head>
<title>Setting Basefont Color</title>
</head>
<body>
<basefont face = "arial, verdana, sans-serif" size = "2" color = "#ff0000">
<p>This is the page's default font.</p>
<h2>Example of the <basefont> Element</h2>
</html>
8
This will produce the following result
ACTIVITY 1: Match the following items. Write only the letter of the correct answer
in your answer sheet.
A. B.
9
SUMMATIVE EVALUATION
A. Write True if the statement is correct, otherwise write False. Write your answer
in your answer sheet.
1. In hexadecimal code, the first two digits(RR) represent a blue value, the next two
are a blue value(GG), and the last are the red value(BB)
2. The font tag is having three attributes called size, height, and face to customize
your fonts.
3. It is possible to specify two or more font face alternatives by listing the font face
names, separated by a comma.
4. The range of accepted values is from 1(smallest) to 8(largest). The default size of
a font is 1.
B. Provide the correct Hexadecimal Code for the different colors below. Write them
in your answer sheet.
10
Key Answer
1. D
2. G
3. H
4. E
5. F
6. A
7. B
8. J
9. C
10. I
Reference: https://www.tutorialspoint.com/html/html_comments.htm
Learn to Code HTML & CSS –Develop and Style Website by: Shay Howe
11
ANSWER SHEET
12