Javascript DOM CSS Style textIndent Property get

Introduction

Return the text indentation of a <div> element:

alert(document.getElementById("myDiv").style.textIndent);

View 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>

<p id="demo"></p>
<script>
function myFunction() {//from w  ww  .  ja v  a2 s .  co m
  document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.textIndent;
}
</script>

</body>
</html>



PreviousNext

Related