473,480 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

span won't honor width... div will, but always have line break before and after

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: yellow">a</span>b
<div style="width: 100px; background: yellow">a</div>b
1) the a and b will stick together for the first line, so span doesn't
honor the "width: 100px"

2) the div honors the "width: 100px", as the background is shown
yellow. but it will force a line break both before the div and after
the div.

Oct 25 '07 #1
5 20014
rf

"Summercool" <Su************@gmail.comwrote in message
news:11**********************@k35g2000prh.googlegr oups.com...
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: yellow">a</span>b
<div style="width: 100px; background: yellow">a</div>b
1) the a and b will stick together for the first line, so span doesn't
honor the "width: 100px"
Read the spec,
http://www.w3.org/TR/CSS21/visudet.html#propdef-width

Width specifically does not apply to [non-replaced] inline elements. Span is
an inline element.

If a browser "honors" width for an inline element then that browser is
broken.
2) the div honors the "width: 100px", as the background is shown
yellow.
Yes. Div is a block element and so width will apply to it.
but it will force a line break both before the div and after
the div.
Yes, that is what block level elements do.

--
Richard.
>

Oct 26 '07 #2
On Oct 25, 5:17 pm, "rf" <r...@invalid.comwrote:
"Summercool" <Summercooln...@gmail.comwrote in message

news:11**********************@k35g2000prh.googlegr oups.com...
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: yellow">a</span>b
<div style="width: 100px; background: yellow">a</div>b
1) the a and b will stick together for the first line, so span doesn't
honor the "width: 100px"

Read the spec,http://www.w3.org/TR/CSS21/visudet.html#propdef-width

Width specifically does not apply to [non-replaced] inline elements. Span is
an inline element.

If a browser "honors" width for an inline element then that browser is

IE 7.0 is honoring span width 100px, so IE 7.0 is broken? (both
quick mode or non-quirk mode).

by the way, how can i have an inline element (go with natural flow),
but has a width of 100px?

using div with display: inline won't work.

Oct 26 '07 #3
rf

"Summercool" <Su************@gmail.comwrote in message
news:11**********************@v23g2000prn.googlegr oups.com...
On Oct 25, 5:17 pm, "rf" <r...@invalid.comwrote:
>"Summercool" <Summercooln...@gmail.comwrote in message

news:11**********************@k35g2000prh.googleg roups.com...
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: yellow">a</span>b
<div style="width: 100px; background: yellow">a</div>b
1) the a and b will stick together for the first line, so span doesn't
honor the "width: 100px"

Read the spec,http://www.w3.org/TR/CSS21/visudet.html#propdef-width

Width specifically does not apply to [non-replaced] inline elements. Span
is
an inline element.

If a browser "honors" width for an inline element then that browser is


IE 7.0 is honoring span width 100px, so IE 7.0 is broken? (both
quick mode or non-quirk mode).
IE6 and IE7 in standards mode conform to the specifications. The width is
ignored.

IE6 and IE7 in quirks mode honour the width so are broken. Given that qurks
mode was invented so as to be compatible with the very broken IE5.x this is
not surprising.

Your postings contain two examples. One puts the browser into quirks the
other into standards mode. Which one are you testing with? In general you
should be always using standards mode, and strict at that.
by the way, how can i have an inline element (go with natural flow),
but has a width of 100px?
You can't. Inline elements have no width attribute. Think about it. Inline
elements are flowed into line boxes. Flowed. What does width mean when the
elements are flowed? Read that section of the specs again.
using div with display: inline won't work.
Correct, because a div with display: inline is an inline element.

What is it you are trying to achieve. It is very possible that you are
solving the wrong problem.

--
Richard.
Oct 26 '07 #4
On Oct 25, 7:24 pm, "rf" <r...@invalid.comwrote:
"Summercool" <Summercooln...@gmail.comwrote in message

news:11**********************@v23g2000prn.googlegr oups.com...
On Oct 25, 5:17 pm, "rf" <r...@invalid.comwrote:
"Summercool" <Summercooln...@gmail.comwrote in message
>news:11**********************@k35g2000prh.googleg roups.com...
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: yellow">a</span>b
<div style="width: 100px; background: yellow">a</div>b
1) the a and b will stick together for the first line, so span doesn't
honor the "width: 100px"
Read the spec,http://www.w3.org/TR/CSS21/visudet.html#propdef-width
Width specifically does not apply to [non-replaced] inline elements. Span
is
an inline element.
If a browser "honors" width for an inline element then that browser is
IE 7.0 is honoring span width 100px, so IE 7.0 is broken? (both
quick mode or non-quirk mode).

IE6 and IE7 in standards mode conform to the specifications. The width is
ignored.

IE6 and IE7 in quirks mode honour the width so are broken. Given that qurks
mode was invented so as to be compatible with the very broken IE5.x this is
not surprising.

Your postings contain two examples. One puts the browser into quirks the
other into standards mode. Which one are you testing with? In general you
should be always using standards mode, and strict at that.
by the way, how can i have an inline element (go with natural flow),
but has a width of 100px?

You can't. Inline elements have no width attribute. Think about it. Inline
elements are flowed into line boxes. Flowed. What does width mean when the
elements are flowed? Read that section of the specs again.
using div with display: inline won't work.

Correct, because a div with display: inline is an inline element.

What is it you are trying to achieve. It is very possible that you are
solving the wrong problem.
are you sure IE 7.0 will not honor the span's widht? because the
script above, IE 7.0 is honoring the span width for the first line.

now... can it still make sense to have inline element and specify the
width, for example, if i have an inline image of 60 px, and i want to
make it a width of 100px? i think i can use margin-left and right for
20px, but can't i use width -- just think of copying the 60px wide
image and pasting it into a newly-created image of 100px width.

the problem i am trying to solve is... without using table, i was
thinking of just arranging several 100px width and height boxes in one
row, and each containing a 75 x 75 image inside...

i suppose i can use float, with div
or span, with margins
or table

just that span with width won't work.

Oct 26 '07 #5
On 2007-10-26, Summercool <Su************@gmail.comwrote:
[...]
are you sure IE 7.0 will not honor the span's widht?
One can never be sure what IE 7.0 will do. The only thing one can say
with certainty is that it _should_ not honour the span's width.
>because the
script above, IE 7.0 is honoring the span width for the first line.

now... can it still make sense to have inline element and specify the
width, for example, if i have an inline image of 60 px, and i want to
make it a width of 100px?
Yes you can set the width of an image because it's a "replaced" inline
element. I believe rf already said this.
i think i can use margin-left and right for
20px, but can't i use width
Yes you can use margins (although there may limits on negative margins),
but you cannot use width.
the problem i am trying to solve is... without using table, i was
thinking of just arranging several 100px width and height boxes in one
row, and each containing a 75 x 75 image inside...
What you want is display: inline-block. But it isn't supported in the
current version of Firefox. It may however work in IE7 if you set widths
explicitly on the inline-blocks, which it sounds like you are planning
to do.
i suppose i can use float, with div
or span, with margins
or table

just that span with width won't work.
Most people use float as you suggest.
Oct 26 '07 #6

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

Similar topics

2
3162
by: Alex Shi | last post by:
In php, is there a way obtain the width of a charactor of a certain font? Alex -- ================================================== Cell Phone Batteries at 30-50%+ off retail prices!...
13
3371
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
5
29420
by: Kathryn | last post by:
Good morning! I am having a problem with a span. I have items, of which I only want to show the first X characters on the screen. If the user prints the page, I want the entire item to print....
1
3550
by: .rhavin | last post by:
I'm trying to put Accords above my Lyrics. Unfortunately, it's all fine in Opera but won't work in IE... any suggestions? (thanx for help) example-code: <html><head> </head><body> <p...
6
2813
by: hsomob1999 | last post by:
so i have a <ul> and I allow the user to append items to it. The problem is that on mozilla the <span class="line"> which is just a line to divide the sections gets overlaped and doesnt move down...
9
6994
by: developer | last post by:
Does anyone know what is the way IE treats span tags(<span>) and table tags(<tr>, <td>)? Should the <span> tag be encolsed in tds and trs if it placed with other elements that are in a table? Can...
10
8462
by: fjleon | last post by:
Hi, i am stuck using older ASP and have to dinamically fill a converted-word file as a form. Let´s suppose a row on a table has the name of someone like in a declaration: <span>Some random...
1
6041
by: rynato | last post by:
I have a <spanof width X px and height Y px. I want to read the text of an article, which is stored in a mySQL table, and pass to that <spanonly just enough text to fit in it, along with a 'read...
6
4462
by: liketofindoutwhy | last post by:
There is a link that encloses a span (or a div), but the link won't work in IE 7 (clicking on video image works, but not on the play button), while it works well in Firefox 2 and 3, and Safari 3....
0
7049
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
7092
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
6981
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
5348
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
4790
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
4488
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
2989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1304
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 ...
0
188
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...

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.