
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Setting Font Size with Keywords Using CSS
The CSS font-size property can be set with absolute and relative keywords. This scales the text as desired.
Syntax
The syntax of CSS font-size property is as follows −
Selector { font-size: /*value*/ }
The following table lists the standard keywords used in CSS −
Sr.No | Value & Description |
---|---|
1 | medium Sets the font-size to a medium size. This is default |
2 | xx-small Sets the font-size to an xx-small size |
3 | x-small Sets the font-size to an extra small size |
4 | small Sets the font-size to a small size |
5 | large Sets the font-size to a large size |
6 | x-large Sets the font-size to an extra-large size |
7 | xx-large Sets the font-size to an xx-large size |
8 | smaller Sets the font-size to a smaller size than the parent element |
9 | larger Sets the font-size to a larger size than the parent element |
The following examples illustrate how CSS font-size property can be set with keywords.
Example
<!DOCTYPE html> <html> <head> <style> h1{ font-size: larger; } #demo { font-size: medium; text-align: center; background-color: floralwhite; } p { font-size: xx-large; } </style> </head> <body> <h1>Demo Heading</h1> <p id="demo">This is demo text.</p> <p>This is another demo text.</p> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> div { margin: auto; padding: 5px; width: 30%; border: 1px solid; border-radius: 29%; text-align: center; font-size: xx-small; } p { font-size: xx-large; } </style> </head> <body> <div> <div>One</div> <p>Two</p> </div> </body> </html>
Output
This gives the following output −
- Related Articles
- Setting Font Size with Keywords in CSS
- Setting Font Size with Em Using CSS
- Setting Font Size with Pixels using CSS
- Setting Font Size with Em in CSS
- Setting Font Size with Pixels in CSS
- Set Font Size with Pixels using CSS
- Set Font Size with em using CSS
- Set Responsive Font Size using CSS
- Set the font size with CSS
- Font Size in CSS
- How to change the font size using CSS?
- How to auto-adjust font size using CSS?
- Setting the size of the radial gradients using CSS
- Font size adjust of an element with CSS
- CSS font-size-adjust Property

Advertisements