Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the font size of html tag [duplicate]

I'm trying to get the root font size of an html file. below is my html:

<html>
<head>
    <title>el query</title>
    <style type="text/css">
        html {
            font-size: 10px;
        }
        html, body {
            height: 100%;
            width: 100%;
            margin: 0;
        }
    </style>
</head>
<body>
    <div id="testDivWrapper">
        <div id="testDiv">
            <div class="child">
                <div class="target"></div>
            </div>
        </div>
    </div>
</body>
</html>

but when i try to get any font information, I am not able to get any font information. I have tried using the following js:

document.documentElement.style.fontSize
document.body.style.fontSize

but i come up with empty strings. any ideas?

like image 926
Michael McLaughlin Avatar asked Feb 24 '15 02:02

Michael McLaughlin


People also ask

How do you double font size in HTML?

To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size. HTML5 do not support the <font> tag, so the CSS style is used to add font size.

How do I change font size in HTML tag?

In HTML, you can change the size of text with the <font> tag using the size attribute. The size attribute specifies how large a font will be displayed in either relative or absolute terms. Close the <font> tag with </font> to return to a normal text size.


1 Answers

window.getComputedStyle(document.body).getPropertyValue('font-size');
like image 159
Ignus Kritzinger Avatar answered Oct 14 '22 08:10

Ignus Kritzinger