/    Sign up×
Community /Pin to ProfileBookmark

I need some help getting an indentation to line up correctly

I have a page that has what is in effect an ordered list, but I cannot figure out a good way to format it correctly.

It is a list of sessions and descriptions – here is an example:

Session 17: Blah blah blah blah blah blah blah blah blah blah
Sessions 18-19: Blah blah blah blah blah blah blah blah blah blah blah blah
Session 20: Blah blah blah blah blah
Session 21: Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
Session 22: Blah blah blah blah blah blah blah blah blah blah
Session 23: Blah blah blah blah blah blah
Session 24: Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

The descriptions will be different lengths. Some of the descriptions will fit onto one line, but some will not. For those that do not, I need the 2nd line to be indented so that it lines up with the beginning of the description, not the Session number. Using {text-indent:-2em; margin-left:2em;} or something like it will not work, because the width of the Session number will not be constant, particularly in the Sessions 18-19 line.

Another thought that I had was to put the sessions in one div and the descriptions in another div and line them up next to each other, but I am worried about disconnecting the two, in terms of maintaining alignment and also screwing up the logic of the page.

The third thought that I had was putting this into a table, but I don’t really like that solution either.

Surely someone out there has had a similar problem and can provide a little advice?

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@timdentyOct 12.2006 — You could try putting the text you want indented into a <span> tag and style it accordingly. This will allow you to target the text you want, whilst not affecting the rest of the list item.
Copy linkTweet thisAlerts:
@House_of_HausauthorOct 12.2006 — How would I do that? <span> is inline, correct? How can I get an inline element positioned so that it maintains a margin over multiple lines?
Copy linkTweet thisAlerts:
@timdentyOct 12.2006 — OK - I've had a quick look and done a workaround for it. It's all scalable in various browsers, but it does require you to set a width for the indent, so it's not perfect...

Try this for starters...


--------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title></title>

</head>

<style type="text/css">

ol span {

display: block;

margin-top: -1.2em;

margin-left: 10em;

}

</style>

<body>

<ol>

<li>Option 1 -<span>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.</span></li>

<li>Option 2 -<span>Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.</span></li>

<li>Option 347245289 -<span>Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC.</span></li>

<li>Option 4 -<span>This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</span></li>

</0l>


</body>

</html>


----------------------------------------------

Tim
Copy linkTweet thisAlerts:
@House_of_HausauthorOct 12.2006 — That is [i]very[/i] helpful - thank you so much!
×

Success!

Help @House_of_Haus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...