473,473 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Correctly define WIDTH in css for inline elements

I'm trying to use CSS for menu buttons, but am unsure how to specify
the width of blocks when displaying them inline.

At the moment I am using SPAN tags, and IE renders the WIDTH property,
but I understand that this is not standard CSS, and Mozilla ignores
width on these inline tags.

I've tried various alternatives with DIVs etc, but that always seems
to render with line breaks after each one - what I want is to show the
menu as it currently displays in IE, but for it to work in Mozilla
too.

This is the example code I am working with - it displays all the
buttons with equal WIDTH in IE (which is what I want), but not in
Mozilla:

--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Test Website</title>
<style>
.navbutton {
font-weight: bold;
text-align: center;
margin-bottom: 3px;
margin-top: 3px;
}

.navbutton a {
padding: 4px;
text-decoration: none;
width: 8em;
color: #224059;
background-color: #b5c9e2;
border-top: 2px #cce3ff solid;
border-left: 2px #cce3ff solid;
border-bottom: 2px #31557f solid;
border-right: 2px #31557f solid;
}

.navbutton a:hover {
background-color: #99aabf;
border-top: 2px #31557f solid;
border-left: 2px #31557f solid;
border-bottom: 2px #cce3ff solid;
border-right: 2px #cce3ff solid;
}
</style>
</head>

<body>

<span class="navbutton"><a href="buttons.htm">News</a></span>
<span class="navbutton"><a href="buttons.htm">Diary</a></span>
<span class="navbutton"><a href="buttons.htm">Library</a></span>
<span class="navbutton"><a href="buttons.htm">Join Us</a></span>
<span class="navbutton"><a href="buttons.htm">Contacts</a></span>

</body>
</html>
Jul 20 '05 #1
5 13698
Colin Jones wrote:
I'm trying to use CSS for menu buttons, but am unsure how to specify
the width of blocks when displaying them inline.
As you learned, you cannot specify width of inline elements.
At the moment I am using SPAN tags, and IE renders the WIDTH property,


Again, as you know, IE is wrong with regard to the spec. Would
floating div elements work?

--
Brian
follow the directions in my address to email me

Jul 20 '05 #2
Colin Jones wrote:
I'm trying to use CSS for menu buttons, but am unsure how to specify
the width of blocks when displaying them inline.
In current versions of CSS - you can't. I believe that inline-blocks appear
in CSS 2.1
At the moment I am using SPAN tags, and IE renders the WIDTH property,
This is a mistake
but I understand that this is not standard CSS, and Mozilla ignores correctly ^ width on these inline tags.

I've tried various alternatives with DIVs etc, but that always seems
to render with line breaks after each one - what I want is to show the
This is why we have the magic of float.
menu as it currently displays in IE, but for it to work in Mozilla
too.


http://css.maxdesign.com.au/listamatic/ - look at the horizontal section.

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #3
se*****@hotmail.com (Colin Jones) wrote in message news:<5e*************************@posting.google.c om>...
I'm trying to use CSS for menu buttons, but am unsure how to specify
the width of blocks when displaying them inline.


Use a table.
Jul 20 '05 #4

"Colin Jones" <se*****@hotmail.com> wrote in message
news:5e*************************@posting.google.co m...
I'm trying to use CSS for menu buttons, but am unsure how to specify
the width of blocks when displaying them inline.

At the moment I am using SPAN tags, and IE renders the WIDTH property,
but I understand that this is not standard CSS, and Mozilla ignores
width on these inline tags.

I've tried various alternatives with DIVs etc, but that always seems
to render with line breaks after each one - what I want is to show the
menu as it currently displays in IE, but for it to work in Mozilla
too.

This is the example code I am working with - it displays all the
buttons with equal WIDTH in IE (which is what I want), but not in
Mozilla:

--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Test Website</title>
<style>
.navbutton {
font-weight: bold;
text-align: center;
margin-bottom: 3px;
margin-top: 3px;
}

.navbutton a {
padding: 4px;
text-decoration: none;
width: 8em;
color: #224059;
background-color: #b5c9e2;
border-top: 2px #cce3ff solid;
border-left: 2px #cce3ff solid;
border-bottom: 2px #31557f solid;
border-right: 2px #31557f solid;
}

.navbutton a:hover {
background-color: #99aabf;
border-top: 2px #31557f solid;
border-left: 2px #31557f solid;
border-bottom: 2px #cce3ff solid;
border-right: 2px #cce3ff solid;
}
</style>
</head>

<body>

<span class="navbutton"><a href="buttons.htm">News</a></span>
<span class="navbutton"><a href="buttons.htm">Diary</a></span>
<span class="navbutton"><a href="buttons.htm">Library</a></span>
<span class="navbutton"><a href="buttons.htm">Join Us</a></span>
<span class="navbutton"><a href="buttons.htm">Contacts</a></span>

</body>
</html>


Try using a list. Have a look at how I did it on www.cloughtonpc.org.uk

Jools
Jul 20 '05 #5
David Dorward <do*****@yahoo.com> wrote in message news:<bn*******************@news.demon.co.uk>...
Colin Jones wrote:
I'm trying to use CSS for menu buttons, but am unsure how to specify
the width of blocks when displaying them inline. .... menu as it currently displays in IE, but for it to work in Mozilla
too.


http://css.maxdesign.com.au/listamatic/ - look at the horizontal section.


Thanks - that site is really great, I'm sure I'll be able to work it
out from the examples on there.

Cheers!
Colin.
Jul 20 '05 #6

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

Similar topics

2
by: Randall Sell | last post by:
Hmmm, have now spent a day reading the entire web with no answer yet! so now resorting again to the experts... I'm trying to create a horizontal list. This is easy enough doing: <html> <head>...
8
by: Harlan Messinger | last post by:
I created a page, currently viewable at http://mywebpages.comcast.net/hmessinger/cssbuttons1.html that displays a couple of buttons simulated with styles applied to <span> tags. The buttons...
3
by: Heath | last post by:
What might cause a div to refuse to go to the width that I have tried to set for it? See #mainBody and .box Here are the styles and the html below: body, #container { padding: 10px 10px...
6
by: bugbear | last post by:
I've spent the last 2 days reading in waaay too much detail the specs for CSS and HTML. I am attempting something very simple. I wish to wrap an image and caption in a span, so that the text can...
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...
14
by: Haines Brown | last post by:
I know I'm missing something obvious. I need a short horizontal rule to preceed a line of text (in a bibliography in which the author is repeated). I tried this: <p> <div class="rule"></div>,...
5
by: Summercool | last post by:
wow... i didn't know that, for <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd"> <span style="width: 100px; background:...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
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...
0
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...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.