By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,974 Members | 1,913 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,974 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.