473,396 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with <UL> and CSS

Dear Readers,

With the following CSS I wanted to create a list,
where there is no empty line between the 'title' and the list.
Also put the bullets closer to the left margin.
And the spacing between two list should be one line.

ul.tight {margin-top:0em; margin-left:1.3em;}

The html then looks like this

<p>
<b>Here goes the title one</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</p>

<p>
<b>Here goes the title two</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</p>

Now this renders fine on IE, but not on FireFox or Opera.
Which puts an empty line between de title and the list.

Later I looked in the HTML specs and I found that:
One should not put <ul></ul> inside <p></p>.

Has anyone a suggestion how to do this
so it will render correct on most browsers?

Tia Jean.
Jul 24 '05 #1
6 6955
"Jean Pion" <je*******@hotmail.com> wrote:
With the following CSS I wanted to create a list,
where there is no empty line between the 'title' and the list.
Also put the bullets closer to the left margin.
And the spacing between two list should be one line.

ul.tight {margin-top:0em; margin-left:1.3em;}

The html then looks like this

<p>
<b>Here goes the title one</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</p>


Change it to

<p class="listhdr"><b>Here goes the title one</b></p>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>

Then remove the spacing with CSS:

p.listhdr{bottom-margin:0;top-margin:1.3em}
ul.tight{top-margin:0;bottom-margin:1.3em}

--
Spartanicus
Jul 24 '05 #2
Spartanicus wrote:
<p class="listhdr"><b>Here goes the title one</b></p>


'listhdr' standing for 'List Header' we presume? So a <hx> element
would perhaps be more appropriate?

Steve

Jul 24 '05 #3
"Spartanicus" <in*****@invalid.invalid> wrote in message
news:r6********************************@news.spart anicus.utvinternet.ie...
"Jean Pion" <je*******@hotmail.com> wrote:
With the following CSS I wanted to create a list,
where there is no empty line between the 'title' and the list.
Also put the bullets closer to the left margin.
And the spacing between two list should be one line.

ul.tight {margin-top:0em; margin-left:1.3em;}

The html then looks like this

<p>
<b>Here goes the title one</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</p>


Change it to

<p class="listhdr"><b>Here goes the title one</b></p>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>

Then remove the spacing with CSS:

p.listhdr{bottom-margin:0;top-margin:1.3em}
ul.tight{top-margin:0;bottom-margin:1.3em}

--
Spartanicus


Thanks Spartacus,

I think you mean "margin-top" top etc. ?

The real sollution is NOT to use <ul> inside <p>
Apearantly FF and Opera are a bit picky about this.
If instead of <p> a <div> is used, things look a lot beter.
Except that FF has a bit of padding by default,
so we need the following in the css:

ul.tight {margin: 0em 0em 1em 1.3em; padding: 0em; }

and the proper html seems to be:

<div><b>Here goes the title one</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</div>

Now the three browser render the page *almost* the same.

Any comments on this?

Jean.
Jul 24 '05 #4
"Jean Pion" <Je*******@hotmail.com> wrote:
<p class="listhdr"><b>Here goes the title one</b></p>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>

Then remove the spacing with CSS:

p.listhdr{bottom-margin:0;top-margin:1.3em}
ul.tight{top-margin:0;bottom-margin:1.3em}

--
Spartanicus
Thanks Spartacus,


Who?

Please configure your news reader to strip out sigs, or snip them
manually when following up.
I think you mean "margin-top" top etc. ?
Oops indeed.
The real sollution is NOT to use <ul> inside <p>
I didn't.
Apearantly FF and Opera are a bit picky about this.
They have every right to be, it's invalid HTML.
If instead of <p> a <div> is used, things look a lot beter.


That might work if it's appropriate for the content to be read out
without a preceding or trailing pause. If not then a paragraph is the
correct markup for list "headers".

--
Spartanicus
Jul 24 '05 #5
"Spartanicus" <in*****@invalid.invalid> wrote in message
news:27********************************@news.spart anicus.utvinternet.ie...
"Jean Pion" <Je*******@hotmail.com> wrote:

Thanks Spartacus,
Who?


Sorry, I missread/typed your name.

Please configure your news reader to strip out sigs, or snip them
manually when following up.

Ok
The real sollution is NOT to use <ul> inside <p>
I didn't.


You are quite right, I should have written:

The real mistake I made was to use <ul> inside <p>.
If instead of <p> a <div> is used, things look a lot beter.


That might work if it's appropriate for the content to be read out
without a preceding or trailing pause. If not then a paragraph is the
correct markup for list "headers".

There is 1 line spacing rendered between 2 sections:

<div><b>Here goes the title one</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</div>

<div><b>Here goes the title two</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</div>

But this spacing is caused by <ul></ul>,
because I specified a bottom margin 1em in de css:
ul.tight {margin: 0em 0em 1em 1.3em; padding: 0em; }

Which is a bit ...tricky?

Jean.
Jul 24 '05 #6
"Jean Pion" <Je*******@hotmail.com> wrote:
There is 1 line spacing rendered between 2 sections:

<div><b>Here goes the title one</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</div>

<div><b>Here goes the title two</b>
<ul class=tight>
<li>item one</li>
<li>item two</li>
<li>item three</li>
<ul>
</div>

But this spacing is caused by <ul></ul>,
because I specified a bottom margin 1em in de css:
ul.tight {margin: 0em 0em 1em 1.3em; padding: 0em; }

Which is a bit ...tricky?


Why? You wouldn't want two consecutive lists to be displayed with no
spacing would you?

--
Spartanicus
Jul 24 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: bearclaws | last post by:
I am looping through a list of categories and want to display the list horizontally (instead of vertically). I want to create a single row with 4 list items in each cell of the row. I thought...
9
by: Akseli Mäki | last post by:
Hi, the subject say quite a lot. I have about the following code(4.01 transitional): <p>blaa blaa blaa <ul> <li><a href="foo.html">foo</a></li> <li><a href="bar.html">bar</a></li> </ul>
1
by: Randall Sell | last post by:
OK, I am utterly stumped. The code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <style type="text/css"> ul {...
5
by: toylet | last post by:
Attached is some css codes for a website. It has 3 parts: top-bar, side-bar (on the left) and main-body. The top-bar has a mouseover menu called top-menu implemented via ul:hover. When the mouse...
4
by: abs | last post by:
Anybody has an idea how to get the <ul> element which is not nested in <li> element ? In other words I have several lists like this: <ul id="1"> <li>Aaaaaaaa</li> <li>Bbbbbbbb</li>...
2
by: Shaun | last post by:
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...
5
by: Syl | last post by:
Hello experts!! The top menu navigation bar displays perfectly in IE, but does not display properly in Mozilla or Netscape : http://checkeredshirt.com/textonly.html For some reason the non-IE...
3
by: Man-wai Chang | last post by:
A 2 columns x 10 rows matrix input form <ul> <li> <ul> <li>item name 1 <li><input type="textbox" name="input_col_1_row_1"> <li><input type="textbox" name="input_col_1_row_2"> </ul> <li>
6
by: capricious | last post by:
Is it possible, so that when you do multiple <UL>'s to control how deep the UL's are marked? For example, it would defaultly look like this with multiple ULs and LIs: -- Code : Main...
2
by: Shahid | last post by:
Hi, I am parsing an .HTML file that contains following example code: <div> <p class="html_preformatted" awml:style="HTML Preformatted" dir="ltr" style="text-align:left"><span...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.