Return the text indentation of a <div> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:textIndent

Description

Return the text indentation of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="text-indent:3cm;">
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</div><br>

<button type="button" onclick="myFunction()">Return text indentation of div</button>

<script>
function myFunction() {//from  ww  w. j a va 2s  . c o  m
    console.log(document.getElementById("myDiv").style.textIndent);
}
</script>

</body>
</html>

Related Tutorials