473,405 Members | 2,287 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,405 software developers and data experts.

CSS: width for <li>

Hi!

li
{
display: inline;
}

<li>foo bar</li>
<li>blah</li>

This make both list item to appear next to another rather then from top
to bottom. However, I want both to have the same width. Setting width in
the above CSS doesn't so the job.

What am I going to do here?

Timo
Jul 20 '05 #1
3 69150
Timo Nentwig wrote:
Hi!

li
{
display: inline;
}

<li>foo bar</li>
<li>blah</li>

This make both list item to appear next to another rather then from top
to bottom. However, I want both to have the same width. Setting width in
the above CSS doesn't so the job.
That's because the width property doesn't apply to non-replaced inline
elements.

<URL:http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-width>

What am I going to do here?


Either:

li {
display: table-cell;
width: 10em;
}

....or:

li {
display: block;
width: 10em;
float: left;
}

The former doesn't work in Internet Explorer, the latter may require a
cleared element following it in the flow.

By the way, this is a stylesheet question, which is better off in the
<URL:news:comp.infosystems.www.authoring.styleshee ts> newsgroup.
Crossposted, followups set.
--
Jim Dabell

Jul 20 '05 #2

"Timo Nentwig" <tc*@spamgourmet.org> wrote in message
news:c4*************@ID-18956.news.uni-berlin.de...
Hi!

li
{
display: inline;
}

<li>foo bar</li>
<li>blah</li>

This make both list item to appear next to another rather then from top
to bottom. However, I want both to have the same width. Setting width in
the above CSS doesn't so the job.

What am I going to do here?

Timo


Width has no affect on inline elements. You could remove the display: inline
and add this to your stylesheet:

li {
float: left;
width: x /* whatever width you need */
}

Regards,
Jim Roberts
Jul 20 '05 #3
Jim Roberts:
Width has no affect on inline elements. You could remove the display: inline
and add this to your stylesheet: li {
float: left;
width: x /* whatever width you need */


Finding "whatever width you need" is however not a trivial matter, since
the element contains text, and you can never know how much space text
will actually take (no matter how much you try to control its size).

So you'd better specify the width in "em" units using a bit more than
you seem to need.

--
Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com>
Jul 20 '05 #4

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

Similar topics

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: Matt | last post by:
Hi, Got an unordered list with 100% width, with 5 list items of 20% width styled to fill the width of the container element. Renders fine in Mozilla, but when you change the size of the window...
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...
2
by: mike_newsgroups | last post by:
Hello everyone, Anyone know how can I change the 30px below to a different value from a javascript function? <table> <tr> <td> <div id="star-rating"> <ul>
10
by: BobaBird | last post by:
When <liis set to {max-width:45em;}, the bullets move from the top to the bottom of the <li>. Also, the bullet for a top-level <liends up on the same line as the last <liof its nested list, with...
2
by: GloStix | last post by:
For some reason, FF likes to put a black underline on all my buttons. No matter what I do, it has the line I've tried displaying as block and cursor, anything.. Also I've been trying to get it so...
2
dlite922
by: dlite922 | last post by:
Before you baulk at yet another min-width problem, hear me out. I've been googling for a good hour now and experimenting but at no avail. I have a horizontal UL/LI menu and I want the li width to...
1
by: Chinsu | last post by:
<html> <head> <style> #ex { width: 700px; background: red; float: left; } a, span { display: block;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
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...

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.