Hello,
I am making a website now for my siblings, and it is almost ready, but one thing annoys me. I can't indent the text right!! I used tables and things like that but it never works. Could you guys give an advice what to do?
Thank you very much!
Stef
How to indent text in HTML?
- Li Kao
- Lives in gote
- Posts: 643
- Joined: Wed Apr 21, 2010 10:37 am
- Rank: KGS 3k
- GD Posts: 0
- KGS: LiKao / Loki
- Location: Munich, Germany
- Has thanked: 115 times
- Been thanked: 102 times
Re: How to indent text in HTML?
What purpose do you to indent the text? The reason is very important, so you end up with a choice that reflects the meaning of your indent.
If it's code like text use the <pre> tag. It will result in a fixed space font and no linebreaks by default. So it's fit only for some purposes.
There are spaces like which won't be removed at the beginning of a line. But using them for indentation usually indicates a misunderstanding of what your real goal is. Can be used to indent code thought.
For most uses you don't want html to indent but css. Depending on what you need "margin-left" or "padding-left" could be right.
If it's code like text use the <pre> tag. It will result in a fixed space font and no linebreaks by default. So it's fit only for some purposes.
There are spaces like which won't be removed at the beginning of a line. But using them for indentation usually indicates a misunderstanding of what your real goal is. Can be used to indent code thought.
For most uses you don't want html to indent but css. Depending on what you need "margin-left" or "padding-left" could be right.
Sanity is for the weak.
- fwiffo
- Gosei
- Posts: 1435
- Joined: Tue Apr 20, 2010 6:22 am
- Rank: Out of practice
- GD Posts: 1104
- KGS: fwiffo
- Location: California
- Has thanked: 49 times
- Been thanked: 168 times
Re: How to indent text in HTML?
As much as possible, you want the HTML to just describe the content of a page, and the CSS should describe what the content looks like.
For example your HTML might look like:
Which, by default will look something like:
If you add some CSS to format the paragraphs:
If you have one particular section you want indented differently, you could use some other tag to set it off. One that is good for block-quotes is the blockquote tag.
Which, by default, looks like:
For example your HTML might look like:
Code: Select all
<p>All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy.</p>
<p>All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy.</p>Which, by default will look something like:
Code: Select all
All work and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy. All work
and no play makes Jack a dull boy. All work and
no play makes Jack a dull boy. All work and no
play makes Jack a dull boy.
All work and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy.If you add some CSS to format the paragraphs:
Code: Select all
p {
text-indent: 5ex;
}Code: Select all
All work and no play makes Jack a dull boy.
All work and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy. All work
and no play makes Jack a dull boy. All work and
no play makes Jack a dull boy.
All work and no play makes Jack a dull boy.
All work and no play makes Jack a dull boy.If you have one particular section you want indented differently, you could use some other tag to set it off. One that is good for block-quotes is the blockquote tag.
Code: Select all
<p>All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy.</p>
<blockquote><p>The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</p></blockquote>
<p>All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy.</p>Which, by default, looks like:
Code: Select all
All work and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy. All work
and no play makes Jack a dull boy. All work and
no play makes Jack a dull boy. All work and no
play makes Jack a dull boy.
The quick brown fox jumps over the lazy
dog. The quick brown fox jumps over the
lazy dog. The quick brown fox jumps over
the lazy dog. The quick brown fox jumps
over the lazy dog.
All work and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy.- Stefany93
- Lives with ko
- Posts: 248
- Joined: Wed Jun 23, 2010 12:39 pm
- Rank: KGS 8k
- GD Posts: 0
- KGS: Azumi93
- Online playing schedule: When I am in a mood for Go :D
- Location: Arkansas, USA
- Has thanked: 193 times
- Been thanked: 21 times
- Contact:
Re: How to indent text in HTML?
Thank you very much guys, you are great. Any ideas why the blockquote tag doesn't work in Notepad ++ ? Thank you!