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>