468,786 Members | 1,741 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,786 developers. It's quick & easy.

CSS for All Elements (Bullets <UL> <LI>) Without <DIV ID="">

Hello!

I have a quick question regarding CSS and having it applied to all
elements. I am trying to eliminate the gap between a paragraph and a
list that usually occurs in html and I've found away to do that with
this code:

<p>a</p>
<ul style="margin-top: -20; padding-top: 0">
<li>1</li>
</ul>

However I was hoping to use CSS to do it to all elements and without
using <DIV id="">. Here is an example of the CSS code I have so far,
but you need to use <div id="squish"> around them.

<style type="text/css">
#squish {
width: 10em;
}
#squish ul {
margin-left: 1em;
margin-top: -20;
padding-top: 0;
padding-left: 0;
}
</style>

Is there a way to apply this to all bullets <UL> <LI> on the page
using CSS without having to use <div id="">?

Thanks for your help!

Shaun
Jul 23 '05 #1
2 7308
in comp.infosystems.www.authoring.html, Shaun wrote:
Hello!

I have a quick question regarding CSS and having it applied to all
elements.
Then why are you asking here? alt.html where you asked first is good also
for CSS, but this group is only for HTML. There is
comp.infosystems.www.authoring.stylesheets for CSS.
I am trying to eliminate the gap between a paragraph and a
list that usually occurs in html and I've found away to do that with
this code:

<p>a</p>
<ul style="margin-top: -20; padding-top: 0">
<li>1</li>
</ul>
Which is wrong, as pointed out for you in alt.html
However I was hoping to use CSS to do it to all elements and without
using <DIV id="">.
Then why are you using div with id?
Here is an example of the CSS code I have so far,
but you need to use <div id="squish"> around them. [snip]

Go look for selectors in CSS
Is there a way to apply this to all bullets <UL> <LI> on the page
using CSS without having to use <div id="">?


Most likely, but I fail to understand your question.

ul {background:red;}

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Jul 23 '05 #2
Shaun wrote:
Hello!

I am trying to eliminate the gap between a paragraph and a
list .....


I guess that you have to understand that P and LISTS are blocks and that
blocks provide double 'line leading/breaks/line returns' as a
conventional default. This is done by the browser with a default
margin-bottom and margin-top. (The double line leadings for both are
collapsed to only one double line leading.)

In order to eliminate the double line leading, the margin-bottom for the
preceding Paragraph must be set to zero and the margin-top for the
subsequent List must be set to zero.

--
Gus
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Akbar | last post: by
3 posts views Thread by Jim in Arizona | last post: by
5 posts views Thread by chakradhari.ashish | last post: by
6 posts views Thread by capricious | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.