SteveMurphy Posted March 28, 2007 Share Posted March 28, 2007 Hi.I have a table that contains a list in one of its cells. However, I need to indent the entire list so that it lines up with some text that preceeds the list, but I don't know how to indent the list. Following is the html for my table: <html> <body> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>private java.lang.String</CODE></FONT></TD> <TD><CODE><B>schoolName</B></CODE> <BR/>nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;Name of educational institution the student attends. </BR> <ul> <li>Harvard</li> <li>Princeton</li> <li>Iowa State</li> </ul> </TD> </TR> <TR> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>private java.lang.String</CODE></FONT></TD> <TD><CODE><B>studentId</B></CODE> <BR/>nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;The student's identification number.</TD> </TR> </TABLE> </body> </html> In this examle, I need to have the bullets of the list line up with the word "Name" in "Name of educational institution the student attends." I am constrainted to keeping the non-breaking spaces that preceed the "Name of educational..." sentence.Note that for my sample above, I had to remove the & from nbsp; otherwise your browswer converts the non-breaking spaces to white space an you can't see the & npbs;Can anyone help?Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 28, 2007 Share Posted March 28, 2007 Add a style section to the head and change the margin until it lines up as you want. <html> <head> <style type="text/css"> ul li { margin-left: -10px; } </style> </head> <body> Change the margin there until it lines up like you want. Try different positive and negative values until you get it. Link to comment Share on other sites More sharing options...
jlhaslip Posted March 28, 2007 Share Posted March 28, 2007 Some browsers us padding on lists, so remove all the padding from the list at the same time. Link to comment Share on other sites More sharing options...
SteveMurphy Posted March 29, 2007 Author Share Posted March 29, 2007 Thanks justsomeguy and jhaslip.I tried the technique of adding the style to the <head> element and it worked fine. However, (I know this sounds strange) I don't own the html file as a whole, I'm just inserting tables. This is part of the javadoc process where you add comments/html to Java source files and the Javadoc processor spits out any html you've added into an html file that it creates. There are hundreds of html files produced by the Javadoc process and (although it could be done) it would be difficult to add the style to the <head> element. The Javadoc output references css stylesheets, so I can add the style to those and make this work. Ideally, for the sake of simplicity, I'd like to control the left margin in the list itself.That said, do the <ul> or <li> elements have any attribute that would allow me to contol the left margin?jhaslip -- how do I go about removing padding from the lists?Thanks again for your posts! Link to comment Share on other sites More sharing options...
pulpfiction Posted March 29, 2007 Share Posted March 29, 2007 One way is to use inline style. Problem with this is you need to give styles individually to all tags.<ul style="padding:0px">OR<li style="margin-left: -10px;"> Link to comment Share on other sites More sharing options...
vchris Posted March 29, 2007 Share Posted March 29, 2007 I don't know why you guys use -10px, to me it seems simple. Remove padding and margin and then add whatever. In some designs padding may be more useful than margin and vice versa but if it's a simple list with no really complicated navigation stuff then just remove padding and margin and add something like padding-left: 5px; or margin-left: 5px; . Link to comment Share on other sites More sharing options...
justsomeguy Posted March 29, 2007 Share Posted March 29, 2007 I use the negative values for lists because browsers seem to like to indent them a lot no matter where I tell it padding and margin are 0. It's quicker just to put an exact value there and be done with it. Link to comment Share on other sites More sharing options...
vchris Posted March 29, 2007 Share Posted March 29, 2007 I've never had any issues... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now