Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 21st, 2005, 12:51 AM
darius
Guest
 
Posts: n/a
Default Cleanest CSS way to do nested indents?

Hi

I want to do paragraphs with nested indent, like so

para 1 ....
.........
para 2 .......
.....
para 3 ......
.........

I've tried things like

..indent { margin-left: 3em; }

<p class="indent">
para1
<div class="indent">para2
<div class="indent">para3</div>
</div>
</p>

but the indents aren't cumulative, i.e., it's all first level indent.

I guess I could do

..indent2 { margin-left: 6em; } etc. but that's rather messy if I should
change the indent level.

I could do

li {
list-style-type: none;
}

but on non-CSS browsers I'll get lists with bullets, which isn't what I
want.

Suggestions? Thanks
  #2  
Old July 21st, 2005, 12:51 AM
Jukka K. Korpela
Guest
 
Posts: n/a
Default Re: Cleanest CSS way to do nested indents?

darius <noone@here.invalid> wrote:
[color=blue]
> I want to do paragraphs with nested indent,[/color]

Are they really paragraphs? It's difficult to imagine why they should be
indented in a nested manner.
[color=blue]
> <p class="indent">
> para1
> <div class="indent">para2
> <div class="indent">para3</div>
> </div>
> </p>[/color]

That's invalid markup, so all bets are off. A <p> element must not
contain a <div> element by HTML syntax. The first <div> tag implicitly
closes an open <p> element.

Here's a "keep it simple" approach, which has the drawback that you need
to compute the amounts of indentation:

HTML:

<p>para 1</p>
<p class="level2">para 2</p>
<p class="level3">para 3</p>

CSS:

p { margin-left: 3em; }
p.level2 { margin-left: 6em; }
p.level3 { margin-left: 9em; }

And here's a "make the CSS simpler at the cost of making the HTML more
complicated" approach:

HTML:

<div class="p-container">
<p>para 1</p>
<div class="p-container">
<p class="level2">para 2</p>
<div class="p-container">
<p class="level3">para 3</p>
</div>
</div>
</div>

CSS:

..p-container { margin-left: 3em; }
[color=blue]
> I could do
>
> li {
> list-style-type: none;
> }
>
> but on non-CSS browsers I'll get lists with bullets, which isn't what
> I want.[/color]

But what is important here? Is it acceptable that there is no indentation
when CSS is off? If not, what is really the logical structure of the
data.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
  #3  
Old July 21st, 2005, 12:51 AM
Els
Guest
 
Posts: n/a
Default Re: Cleanest CSS way to do nested indents?

darius wrote:
[color=blue]
> Hi
>
> I want to do paragraphs with nested indent, like so
>
> para 1 ....
> ........
> para 2 .......
> .....
> para 3 ......
> .........
>
> I've tried things like
>
> .indent { margin-left: 3em; }[/color]
[color=blue]
> but the indents aren't cumulative, i.e., it's all first
> level indent.[/color]

Try padding instead of margin.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Ofra Haza - Im Nin'alu
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles