Set text-indent to 10% in HTML and CSS

Description

The following code shows how to set text-indent to 10%.

Example


<!-- w w  w .  j a  va  2s . c  o  m-->
<html>
<head>
<title>text-indent</title>
<style type='text/css'>
body {
font: 14px sans-serif;
}
p {
padding: 5px 25px;
}
p#indent {
text-indent: 25px;
}
p#indent-percentage {
text-indent: 10%;
}
p#indent-reverse {
text-indent: -25px;
}
p.indent-example {
background: lightyellow;
border: 1px solid darkkhaki;
}
</style>


</head>
<body>
<h4>Indenting Text With CSS</h4>
<p>
Text can be indented by a positive length value, as is demonstrated
by the following paragraph.
</p>
<p class='indent-example' id='indent'>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
</p>
<p>
Text can be indented via a percentage value, as is demonstrated
by the following paragraph.
</p>
<p class='indent-example' id='indent-percentage'>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
</p>
<p>
Finally, text can be reverse indented by providing a negative
length value, which is demonstrated by the following paragraph.
</p>
<p class='indent-example' id='indent-reverse'>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
</p>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set text-indent to 10% in HTML and CSS
Home »
  HTML CSS Tutorial »
    Text »
      CSS Text Style
...
Set font size and color for 'first-letter' ...
Set font size and color for 'first-line' in...
Set negative text indent for list item in H...
Set paragraph to text-indent 3em in HTML an...
Set text-indent to 10% in HTML and CSS
Set text-indent to -25px in HTML and CSS
Set text-indent to 25% in HTML and CSS
Set text-indent to -5% in HTML and CSS
Use margin to indent paragraph in HTML and ...
Set letter-spacing to 10px; in HTML and CSS
Set letter-spacing to 2px in HTML and CSS
Set letter-spacing to negative value in HTM...
Set letter-spacing to normal in HTML and CS...
Compare line-height:normal, 18px, 1.5em, 1....
Compare line height settings in HTML and CS...
Set font-size and line-height in HTML and C...
Set line height for a paragraph in HTML and...
Set line height to 1em in HTML and CSS
Set line-height to 1.4em in HTML and CSS
Set line height to 3em in HTML and CSS
Set line-height to 75% in HTML and CSS
Set line height with various measurements i...
Set paragraph line-height to 150% in HTML a...
Compare text-align all possible values in H...
Set text-align to center in HTML and CSS
Set text-align to justify in HTML and CSS
Set text align to justify to paragraph in H...
Set text-align to left in HTML and CSS
Set text-align to right in HTML and CSS
Compare text-decoration in HTML and CSS
Set text-decoration to line-through in HTML...
Set text-decoration to none for visited anc...
Set text-decoration to overline in HTML and...
Set text-decoration to underline in HTML an...
Set text-decoration to underline overline i...
Set text-decoration to underline overline l...
Compare text-transform in HTML and CSS
Set text-transform to capitalize in HTML an...
...