473,772 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6971
"Jean Pion" <je*******@hotm ail.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{botto m-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
"Spartanicu s" <in*****@invali d.invalid> wrote in message
news:r6******** *************** *********@news. spartanicus.utv internet.ie...
"Jean Pion" <je*******@hotm ail.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{botto m-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*******@hotm ail.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{botto m-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
"Spartanicu s" <in*****@invali d.invalid> wrote in message
news:27******** *************** *********@news. spartanicus.utv internet.ie...
"Jean Pion" <Je*******@hotm ail.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*******@hotm ail.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
4662
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 this would work but I get this error: "End tag 'xsl:if' does not match the start tag 'ul'." Any thoughts?
9
6843
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
3756
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 { background-color: red; }
5
9245
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 pointer hovers over the top-menu, the bottom margin of the top-bar expands downwards. How could I make the hover menu to stack on top of the main-body, not expanding the bottom margin of the top-bar? I believe it has something to do with...
4
2210
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> <li>Cccccccc <ul> <li>111111</li> <li>222222</li>
2
7632
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 away to do that with this code: <p>a</p> <ul style="margin-top: -20; padding-top: 0"> <li>1</li>
5
4485
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 browers are forcing the top navigation menu to dislpay "staggered" after the the first <ul><lielement. Can anyone see why this is happening ?
3
6689
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
4472
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 Menu<ul>Fruits<ul><li>Apples</li><li>Oranges</li></ul></ul> .. -- Returns :
2
2362
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 style="font-size:12pt;font- family:'Arial'" xml:lang="en-US" lang="en-US">Normal Text Arial 12 Black before bullets.</span></p> <ul> <li class="html_preformatted" dir="ltr" style="text- align:left">&nbsp;<span style="font-size:12pt;font-family:'Arial'"
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.