
- 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 in CSS
To set the font size with the font-size property, you can set keywords as well. These keywords are divided into absolute-size or relative-size keywords −
Relative-size keywords
Includes the following keywords: larger, smaller
Absolute-size keywords
Includes the following keywords: xx-small, x-small, small, medium, large, x-large, xx-large, xxx-large
Example
Let us now see an example wherein we will set the font size with Absolute-size keywords −
<!DOCTYPE html> <html> <head> <style> .demo { grid-area: newArea; font-size: xx-large; } .item3 { font-size: small; } .item4 { font-size: medium; } .item5 { font-size: x-large; } .grid-container { display: grid; grid-template-areas: 'newArea newArea . . .' 'newArea newArea . . .'; grid-gap: 5px; background-color: blue; padding: 5px; } .grid-container > div { background-color: orange; text-align: center; padding: 5px 0; } </style> </head> <body> <h1>Heading One</h1> <p>Set some random numbers</p> <div class="grid-container"> <div class="demo">250</div> <div class="item2">120</div> <div class="item3">333</div> <div class="item4">298</div> <div class="item5">645</div> <div class="item6">543</div> <div class="item7">555</div> </div> </body> </html>
Output
Example
Let us now see another example wherein we will set the font size with pixesl −
<!DOCTYPE html> <html> <head> <style> .demo { grid-area: newArea; font-size: smaller; } .item3 { font-size: smaller; } .item4 { font-size: larger; } .item5 { font-size: larger; } .grid-container { display: grid; grid-template-areas: 'newArea newArea . . .' 'newArea newArea . . .'; grid-gap: 5px; background-color: blue; padding: 5px; } .grid-container > div { background-color: orange; text-align: center; padding: 5px 0; } </style> </head> <body> <h1>Heading One</h1> <p>Set some random numbers</p> <div class="grid-container"> <div class="demo">250</div> <div class="item2">120</div> <div class="item3">333</div> <div class="item4">298</div> <div class="item5">645</div> <div class="item6">543</div> <div class="item7">555</div> </div> </body> </html>
Output
- Related Articles
- Setting Font Size with Keywords Using CSS
- Setting Font Size with Em in CSS
- Setting Font Size with Pixels in CSS
- Setting Font Size with Em Using CSS
- Setting Font Size with Pixels using CSS
- Set the font size with CSS
- Font Size in CSS
- Set Font Size with Pixels using CSS
- Set Font Size with em using CSS
- Setting Tab Sizes in HTML with CSS tab-size Property
- Font size adjust of an element with CSS
- CSS font-size-adjust Property
- Change the font size of a button with CSS
- Usage of font-size property in CSS
- Set Responsive Font Size using CSS

Advertisements