473,241 Members | 1,527 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,241 software developers and data experts.

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 19996
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
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
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
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
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
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
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
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
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
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
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.