CSS font-size property

CSS font-size property

Description

The font-size property affects the size of an element’s text.

Possible values

  • xx-small – Sets the size of an element’s text to be smaller than the value x-small.
  • x-small – Sets the size of an element’s text to be smaller than the value small.


  • small – Sets the size ratio of the element’s text medium is smaller.

  • medium – Sets the element’s text size to be smaller than large and larger than small.

  • large – Sets the element’s text size to be larger than medium.

  • x-large – Sets the element’s text size to be larger than large.

  • xx-large – Sets the element’s text size to be larger than x-large.

  • larger – Sets the element’s text size to be larger than the parent element’s text.

  • smaller – Sets the element’s text to be smaller than the parent element’s text.

  • length – Any allowed length value. Negative length values ​​are not allowed for font-size.

  • percentage – Sets the element’s text size relative to its parent element.

Applies to

All HTML elements.

DOM Syntax

object.style.fontSize = "12pt"; 

Example

Here is an example of using this property:

<html> 
<head> 
</head> 

<body> 
<p style = "font-size:20px;"> 
This font size is 20 pixels 
</p> 

<p style = "font-size:small;"> 
This font size is small 
</p> 

<p style = "font-size:large;"> 
This font size is large 
</p> 
</body> 
</html> 

This will produce the following result –

CSS font-size property

Leave a Reply

Your email address will not be published. Required fields are marked *