In order to set the font size user can use the CSS font-size property. In which value can be defined by the following methods
Absolute-size key words
Which are the keywords are used to set the font-size values, in which each keyword is associated with the a index is used by the browser to compute the font size. For all browsers default scaling index is "1" and size is minimum. In which some possible values are listed below.
- xx-small
- x-small
- small
- medium
- large
- x-large
- xx-large
Absolute size |
xx-small |
x-small |
small |
medium |
large |
x-large |
xx-large |
Scaling Index |
3/5 |
3/4 |
8/9 |
1 |
6/5 |
3/2 |
2/1 |
Heading |
h6 |
|
h5 |
h4 |
h3 |
h2 |
h1 |
The code below demonstrates the Absolute sizes with keywords as shown below.
[html]
<!DOCTYPE HTML>
<html>
<head>
<style>
h1{font-size:x-large;}
p{font-size:medium;}
span{font-size:large;}
</style>
</head>
<body>
<h1>Splessons</h1>
<p>Simple Programming Lessons Tutorials</p></p>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
Relative-size key words
Relative size keywords are mainly divided into two types which are show below.
Larger
Which are used to increase the font size relative to the parent.
Smaller
Which decrease the font size relative to the parent.
For example the font size of the parent is large and the current element value is large then the font size element changed to the "large". The code below demonstrates the CSS relative font size with key words.
[html]
<!DOCTYPE HTML>
<html>
<head>
<style>
h1{font-size:larger;}
p,span{font-size:smaller;}
</style>
</head>
<body>
<h1>SPLESSONS</h1>
<p>Simple Programming Lessons Tutorials</p>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.