Google Answers Logo
View Question
 
Q: Preventing indents on my <LI> tags ( Answered 4 out of 5 stars,   3 Comments )
Question  
Subject: Preventing indents on my <LI> tags
Category: Computers
Asked by: rservice-ga
List Price: $5.00
Posted: 06 Feb 2005 16:24 PST
Expires: 08 Mar 2005 16:24 PST
Question ID: 470040
I would like to prevent the bullet on LI tags from indenting using
both CSS and inline styles.

Curretly, I have a custom <LI> tag outlined in my CSS file which reads:
ul { list-style-image: url("http://MYSERVER.com/images/arrow.gif") }

What would I add or change so that there is no indent?
Answer  
Subject: Re: Preventing indents on my <LI> tags
Answered By: hammer-ga on 08 Feb 2005 10:53 PST
Rated:4 out of 5 stars
 
RService,

A discussion of this along with some CSS you can use can be found at
the alt.html FAQ.
http://www.html-faq.com/faq.php?category=css&fid=163

Note that, as is often the case, different browsers may react
differently to CSS tags.

As another method, since you are using a custom image, you can simply
make your own lists with something like the HTML below, using <BR> to
force line breaks and not using <UL> or <LI> at all.

<IMG SRC="http://MYSERVER.com/images/arrow.gif"> Line 1 Text<BR>
<IMG SRC="http://MYSERVER.com/images/arrow.gif"> Line 2 Text<BR>
<IMG SRC="http://MYSERVER.com/images/arrow.gif"> Line 3 Text<BR>

Good luck with your web project!

- Hammer

Search Strategy
---------------
HTML bulleted list indent

Request for Answer Clarification by rservice-ga on 09 Feb 2005 10:49 PST
I'm sorry, but this won't work for me. It's important that the answer
comes in the form of a CSS method.

I've tried the other methods suggested, including putting the image in
the LI tag and not using a UL tag, but that only gets a regular
bullet. It ignores the image.

Could you please remove this answer; it doesn't do it.

Clarification of Answer by hammer-ga on 09 Feb 2005 11:16 PST
RService,

I have no ability to remove the answer. If you are dissatisfied, you
can request a refund using the method described below.
http://answers.google.com/answers/faq.html#refund

- Hammer

Clarification of Answer by hammer-ga on 09 Feb 2005 16:53 PST
RService,

Just as a note, the syntax below worked perfectly for me in IE. I was
able to adjust the indent at will by changing the margin-left
specification. This also worked in Netscape, if I set the margin to a
negative number, such as -10px.

If there is a particular browser or combination of browsers that this
must work in, you may want to note which ones, so the next person can
test in that particular browser.

- Hammer

<HTML>
<HEAD>
<style type="text/css">
 ul { margin-left: 0; list-style-image: url("Green_Square3312.gif")}
 li { margin-left: 0; }
</style>
</HEAD>
<BODY>
<UL>
<LI>One</LI>
<LI>Two</LI>
<LI>Three</LI>
</UL>
</BODY>
</HTML>

Request for Answer Clarification by rservice-ga on 10 Feb 2005 09:21 PST
Hi Hammer,

The problem is that the solution I need must reside entirely in the
CSS file, not in any style tags or anywhere else in the HTML file.

Clarification of Answer by hammer-ga on 10 Feb 2005 10:11 PST
RService,

I provided the syntax inside a complete web page so it would be a
self-contained example. You should be able to use the same syntax
inside your CSS file. I just added the margin-left specification to
the example in your question and changed the image name to one I have.

If you add the margin-left to the UL definition in your CSS file, and
also add the LI definition as shown, it should work for you.

- Hammer

Request for Answer Clarification by rservice-ga on 10 Feb 2005 19:24 PST
Thanks -- good point. But I have tried putting it in the CSS file as
well and it turns my custom graphic into a standard bullet, and keeps
the indent (in both Firefox 1.0 and IE6). Here is the code I have now
in my CSS.

ul 	{ list-style-image: url("http://MYSERVER.com/images/arrow.gif";
	  margin-left: 0; }

li 	{ margin-left:		0; 
	  line-height:		140%;
	  padding:		0px 0px 5px 0px;}

Clarification of Answer by hammer-ga on 11 Feb 2005 05:41 PST
RService,

CSS is very fussy about syntax and order. A semicolon out of place (or
similar syntax error) will cause it to ignore portions of your style.
The syntax below works for me in IE, Netscape and Firefox. I was able
to adjust the indent by changing the margin-left setting in the LI.

list.css
------------
 ul { margin-left: 0; list-style-image: url("Green_Square3312.gif")}
 li { margin-left: 0; line-height: 140%; padding: 0px 0px 5px 0px }


list.html
------------
<HTML>
<HEAD>
<link REL=StyleSheet HREF="list.css" TYPE="text/css">
</HEAD>
<BODY>
<UL>
<LI>One</LI>
<LI>Two</LI>
<LI>Three</LI>
</UL>
</BODY>
</HTML>


- Hammer

Request for Answer Clarification by rservice-ga on 12 Feb 2005 10:34 PST
Thanks -- okay this is working in IE6 now... is there any way it can
work in Firefox 1?  I've requested a refund for the non-working answer
here and I'll be happy to have you answer it once it's reposted.

Request for Answer Clarification by rservice-ga on 12 Feb 2005 10:35 PST
Oops -- you ARE the original researcher!  Sorry about that... I'll
close this one now, but would love to know if there's a way to make
this work in Firefox as well.

Clarification of Answer by hammer-ga on 13 Feb 2005 06:09 PST
RService,

As I noted earlier, this does work in Firefox. For
Netscape/Mozilla/Firefox, you can set the margin-left to a negative
number. As different browsers interpret certain CSS tags differently,
you may need to make browser-specific adjustments.

- Hammer
rservice-ga rated this answer:4 out of 5 stars

Comments  
Subject: Re: Preventing indents on my <LI> tags
From: fjccommish-ga on 07 Feb 2005 00:52 PST
 
The <UL> Tag creates the indent.

The <LI> creates the bullet.

<UL>
<LI>1</LI>
<LI>2</LI>
</UL>

creates an indented bullet list of 1 and 2.  Removing the UL tags
removes the indent.
Subject: Re: Preventing indents on my <LI> tags
From: rservice-ga on 08 Feb 2005 10:04 PST
 
But it doesn't insert the dot (or, in my case, the image)... It also
double-spaces everything, which isn't what I'm after. I want it to be
identical to the LI tage but with no indent.
Subject: Re: Preventing indents on my <LI> tags
From: alloy1-ga on 04 May 2005 17:58 PDT
 
Another great way of creating custom bullets on list items is to use
background images:

For exmaple:

<style type="text/css">
ul, ul li {
    margin: 0;
    padding: 0;
    list-style: none;
}

ul li {
    background-image: url(bullet.gif); /* Replace bullet.gif with your img */
    background-position: left center; /* Position bullet */
    background-repeat: no-repeat;
    padding-left: 10px; /* Add padding so text doesn't cover bullet img */
}
</style>

....

<ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
</ul>


I find this method works really well as the results are consistent
across a good range of browsers (NS 6+, Moz 1.6+, FF 1.0, IE 5+), plus
it can be done entirely in CSS.

Hope this is useful,

Alloy1

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy