For all you beginners to HTML, here’s a simple tutorial just for you explaining how to indent a paragraph. In many HTML popular editors, you are not given a simple way to indent paragraphs so you have to do it manually to achieve the formatting you want. There are a lot of ways to do it but here is a simple and quick method.
Let’s say you’re starting with a block of text like this and you want to indent it on both sides:
Just put your text into the <p> tags with the style markup as shown below:
<p style="margin-left:10%; margin-right:10%;">This is the text that I want to indent. I want to create a margin on both sides so that it doesn't go the full width of the page. Don't ask me why I want to do this. I just do!</p>
As a result, your text will display like this:
The code above is just a paragraph tag with left and right margins set at 10%. You can change the percentage to any number you want to achieve your desired look. You can also use a number of pixels instead of percentage to set the margins. For example, you can set it to 200px left margin and 50px right margin using this code:
<p style="margin-left:200px; margin-right:50px;">This is the text that I want to indent. I want to create a margin on both sides so that it doesn't go the full width of the page. Don't ask me why I want to do this. I just do!</p>
Then your text would look like the paragraph below. Notice the left margin is much larger since we set it to 200px as opposed to 50px on the right side:
This is a quick and simple method to create indented paragraphs if you only have a few paragraphs to indent. If you are formatting an entire website with many pages of text or you plan on changing the formatting often, it may be more efficient to use CSS styles as described on this tutorial from htmlcodetutorial.com.
Questions? Please comment below…