HTML Small Font
Today’s post will teach us how to show small fonts in HTML.
Show Small Fonts in HTML
The font-size
CSS property determines the font size. When the font size is altered, the sizes of the font size-relative length units, such as em
, ex
, and so forth, are also modified.
The font size can be specified in many ways, including using keywords or numerical values expressed in pixels or ems
. Select the suitable approach depending on the specific web page’s requirements.
Syntax:
font-size: value
The thirteen values that font-size
supports are listed as follows:
- The default value for the
font-size
attribute ismedium
, which makes the font size medium. - The
font-size
is set to anxx-small
size by thexx-small
value. - The
x-small
value reduces the text size even further. - The
small
number reduces the text size to small. - The
large
value increases the text size to a large size. - The
font-size
is changed to be extra big using thex-large
option. - The
font-size
is set to a double extra large size by thexx-large
value. - The
font-size
is set to be asmaller
value, smaller than the parent element. - The
larger
number increases the font size above the parent element. - The
length
value establishes a fixedfont-size
in pixels, centimeters, etc. - The
font-size
is set to a percentage of the parent element’s font size using the%
value. - The
initial
value establishes the default value for this attribute. Inherit
attribute is inherited by an element from its parent.
More details on font size are available in the official documentation here.
To further understand the previous concept, consider the following example.
<p style="font-size: medium;">Hello World!</p>
<p style="font-size: 5px;">Hello World!</p>
<p style="font-size: x-small;">Hello World!</p>
<p style="font-size: small;">Hello World!</p>
<p style="font-size: xx-small;">Hello World!</p>
<p style="font-size: xx-large;">Hello World!</p>
<p style="font-size: large;">Hello World!</p>
The above example prints the phrase hello world
with different font sizes. Select the suitable approach depending on the specific web page’s requirements.
Shraddha is a JavaScript nerd that utilises it for everything from experimenting to assisting individuals and businesses with day-to-day operations and business growth. She is a writer, chef, and computer programmer. As a senior MEAN/MERN stack developer and project manager with more than 4 years of experience in this sector, she now handles multiple projects. She has been producing technical writing for at least a year and a half. She enjoys coming up with fresh, innovative ideas.
LinkedIn