How to change the font size in CSS?
The font-size property in CSS affects the size of the text of an element. It is used to specify the height and size of the font. The default value of this property is medium and can be applied to every element. The values of this property are xx-small, small, x-small, etc.
This property has numerous values that are responsible for changing the size of the content. There is the length value that can be in cm, px, pt, etc. Negative values of length are not allowed in font-size.
NOTE: If we do not define a font-size, then for the normal text such as paragraph, the default size is 16px, which is equal to 1em.
The font-size can be absolute or relative. The absolute size sets the text to a definite size, whereas the relative size sets the text relative to the neighboring elements.
Let's understand how to change the size of font by using some illustrations.
Example - Using font-size valuesTest it Now
Example - Using length value
In this example, we are using the length value with em, vw, px, and cm.Test it Now