473,748 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ 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 20032
rf

"Summercool " <Su************ @gmail.comwrote in message
news:11******** **************@ k35g2000prh.goo glegroups.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.c omwrote:
"Summercool " <Summercooln... @gmail.comwrote in message

news:11******** **************@ k35g2000prh.goo glegroups.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.goo glegroups.com.. .
On Oct 25, 5:17 pm, "rf" <r...@invalid.c omwrote:
>"Summercool " <Summercooln... @gmail.comwrote in message

news:11******* *************** @k35g2000prh.go oglegroups.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.c omwrote:
"Summercool " <Summercooln... @gmail.comwrote in message

news:11******** **************@ v23g2000prn.goo glegroups.com.. .
On Oct 25, 5:17 pm, "rf" <r...@invalid.c omwrote:
"Summercool " <Summercooln... @gmail.comwrote in message
>news:11******* *************** @k35g2000prh.go oglegroups.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
3179
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! http://www.pocellular.com ==================================================
13
3403
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 <foo/>) From XHTML specification:
5
29592
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. Thanks to Els, I have a way to do this, see below, directly from the View Source: This is a long piece of text. This is a long piece of text. This
1
3574
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 style="line-height:150%">this is a Te<span
6
2834
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 and adjust to the newly added items like it does in iE. It just occured to me that i dont really have to use a span, and a html <hr> tag could do the trick -I will go try. But aside from that could some one explain why this occurs? And will I get...
9
7133
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 the span tag itself contain table tags within it? I have some scripting code and when I wrap the span in table elements it does not find the html within the span. Here is an example.... <tr><td colspan="4" align="left"><span...
10
8554
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 guy</span>, currently employed at ... The problem is that the location of the next part of the line ("currently employed") varies on the length of the text inside the span.
1
6071
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 more' hyperlink which will take the user to the full article. I do not want any overflow scroll bars to show. The font-size is set by external stylesheet in em's. How can I determine how much text is enough? Approaches I've thought of:
6
4483
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. The intention is to make the link clickable on both the play button and the video image. the page is http://www.0011.com/test/test_link.html the code
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9381
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...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6799
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
6078
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
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
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.