473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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
Jul 20 '05 #1
2 6703
darius <no***@here.invalid> wrote:
I want to do paragraphs with nested indent,
Are they really paragraphs? It's difficult to imagine why they should be
indented in a nested manner.
<p class="indent">
para1
<div class="indent">para2
<div class="indent">para3</div>
</div>
</p>
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; }
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.


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/
Jul 20 '05 #2
Els
darius wrote:
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; } but the indents aren't cumulative, i.e., it's all first
level indent.


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
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Christian Seberino | last post by:
Linux kernel style guide, Guido's C style guide and (I believe) old K&R style recommends 8 SPACES for indent. I finally got convinced of wisdom of 8 space indentation. Guido also likes 8 space...
4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
9
by: ex-neo-con | last post by:
I'd like to write code to make a nested class publicly available, but I want to restrict its instantiation to instances of the containing class. I know I could do such a thing using reflection,...
1
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
6
by: Matthew Graham | last post by:
Hi, I expect this is very obvious for anyone who knows what they're doing - but I don't understand what's the problem with the following code. I was intending that the program cycle through all...
2
by: cloc3 | last post by:
I'm a newbie in python, and I'm fighting against nested blocks in psp. Thats a little example with a funny behaviour: <html> <form> <select name="List"> <!--makes a list with a loop --> <%...
1
by: Tim | last post by:
I ran into a problem with a script i was playing with to check code indents and need some direction. It seems to depend on if tabsize is set to 4 in editor and spaces and tabs indents are mixed on...
9
by: JAF | last post by:
I need help with the following format: 1. Paragragh goes here and text wraps or indents several spaces on second and subsequent lines. 2. Paragragh goes here and text wraps or indents...
2
by: bill | last post by:
The IMAP_headers function returns an associative array. for example: $head = imap_header($in, ($index+1)); echo " <br />header:subject:" . $head->subject; works fine, but $head->from returns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.