You are here: Reference > JavaScript > client-side > HTML DOM > properties > size (basefont, font)

size property (basefont, font)

Browser support:
Specifies or returns the size of the font.
This property is deprecated. Use the font style property or other style properties to manipulate the font types in the entire document.

Syntax:

object.size;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: size

Possible values:

String that sets or retrieves the size of the font.
One of the following values:
absolute
Integer (between 1 and 7) that sets or retrieves the absolute size of the font.
relative
Integer with (+/-) designator sets the font size relative to the basefont element.
Default: 3.

Example HTML code 1:

This example illustrates the use of the size attribute:
<basefont size="5" />basefont size=5
<font size="-3">size=-3</font>
<font size="+2">size=+2</font>

<font size="2">size=2</font>
<font size="5">size=5</font>
<font size="7">size=7</font>
Did you find this example helpful? yes no

Example HTML code 2:

Recommendation:
<body style="font-size:13px;">
    font size 13px
    <span style="font-size:70%;">font-size:70%</span>
    <span style="font-size:80%;">font-size:80%</span>
    <span style="font-size:120%;">font-size:120%</span>
    <span style="font-size:160%;">font-size:160%</span>
    <span style="font-size:340%;">font-size:340%</span>
</body>
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the size property:
<head>
    <script type="text/javascript">
        function GetSize () {
            var fonts = document.getElementsByTagName ("font");

            for (var i = 0; i < fonts.length; i++) {
                alert (fonts[i].size);
            }
        }
    </script>
</head>
<body>
    <basefont size="5" />basefont size=5
    <font size="-3">size=-3</font>
    <font size="+2">size=+2</font>

    <font size="2">size=2</font>
    <font size="5">size=5</font>
    <font size="7">size=7</font>

    <button onclick="GetSize ();">Get font sizes!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content