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?
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.
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.
window.getComputedStyle(document.body).getPropertyValue('font-size');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With