Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

How to indent a multi-line list?

Hi all - Does anyone have any insight on how to go about indenting an unordered list?

I'm using list-style-position: inside.

When I get down to mobile width the longer lines need to indent with the copy, not the bullet. I've seen, and tried, other solutions that use text-indent and padding but those don't work as they don't play well with responsive.

Thanks in advance.

Not specifically sure what you're asking exactly, but maybe try adding a margin-left to the ul, and the whole container will move to the left, however many units of measure you tell it to.

ul {
   margin-left: 50px;
}

This above code would move the entire ul container 50px to the left. Hope this helps...

Perhaps try using % instead of px. When working with responsive percentages can be helpful.

3 Answers

Hi Randy,

It sounds to me like you want all your lines of text to be aligned on the left edge when wrapping. Is that correct?

The initial value for list-style-position is outside

This should have given you the behavior you were looking for.

inside puts the list item marker inside the line box. It's almost like the bullet is now the 1st character of your text. You can think of it like that. So when your text wraps to the next line, the 1st character in that line is going to be under the bullet.

Is there a particular reason why you had to switch to list-style-position: inside?

Based on your diagram I don't think there's going to be a way to solve that in an exact way but hopefully you can get close enough.

I started a codepen demo that duplicates your diagram here: http://codepen.io/anon/pen/aoAte

I changed the browser default left padding of 40px to 0.9em to get it to line up and left the list-style-position value at the default of outside

It seems to do ok with user changes to font-size.

Is it possible for you to fork that demo and show what's happening on the responsive side of things which is causing the other techniques to not work?

Or at least elaborate on what you're doing which made the other techniques not work.

I need the bullets to not hang outside the content area. I did a quick "sketch" to explain it better ...

Diagram here

I tried placing the image directly here but can't get the markdown to work.

Hi all - sorry for the long delay. A bunch of other things took me away from this.

I think perhaps I had a problem where one didn't actually exist. For whatever reason I thought lists didn't indent under the copy. I guess I wasn't having a sharp day (like a lot in my web learning).

Thanks.