Get the font size of a <p> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:fontSize

Description

Get the font size of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="font-size:200%">This is a paragraph.</p>

<button type="button" onclick="myFunction()">Return font size</button>

<script>
function myFunction() {/*w ww . j av  a  2 s.c om*/
    console.log(document.getElementById("myP").style.fontSize);
}
</script>

</body>
</html>

Related Tutorials