CSS Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
CSS Topics
css tutorials Introduction
Types Types
Background Properties Background Properties
Text Properties Text Properties
Font Properties Font Properties
Box Properties BOX Properties
Border Properties Border Properties
Margin Properties Margin Properties
Padding Properties Padding Properties
Special Topics Special Topics
Forums Ask Your Doubts
Scraps More about CSS
Feedback Feedback
 




CSS Font Size


Tutorials Css

Topic

How to set the font size in html using style sheet?



Explanation

Property: Font Size

Usage:
font-size: xx-small;
font-size: x-large;
font-size: larger;
font-size: smaller;
font-size: 10px;
font-size: 80%;

Definition:
The size of the font can be controlled using this parameter in style sheet. The values can be set in three modes.
a) Absolute Size.
b) Relative Size.
c) Length - in percentage / pixels / points.

It takes the following values.

a)Absolute : The following absolute values can be used to set the size of the text. xx-small or x-small or small or large or x-large or xx-large or medium.
b)Relative : The following relative values can be used. larger or smaller
c)Length : In percentage (e.g 34%) or pixels (e.g: 20px) or points (e.g: 20).

Example 1:
<div style="font-size: xx-small;">testing font size </div>

Result:

testing font size


Example 2:
<div style="font-size: x-large;">testing font size </div>

Result:

testing font size


Example 3:
<div style="font-size: larger;">testing font size </div>

Result:

testing font size


Example 4:
<div style="font-size: smaller;">testing font size </div>

Result:

testing font size


Example 5:
<div style="font-size: 20px;">testing font size </div>

Result:

testing font size


Example 6:
<div style="font-size: 200%;">testing font size </div>

Result:

testing font size



Font weight Font family


A Note
CSS - Cascading Style Sheets can be used along with html tags as explained in this site. This simple CSS will help you to create much elegant and neat html web pages. This does not need any additional softwares or codings. All web browser are capable of handing CSS codes.

Note 2: If required you can using <span> instead of <div> tags. div tag will start and end on new lines. span will not exceed the tag area.
Other Links

web hosting