469,568 Members | 1,483 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

Transform a Span into a Div

Hello,

I have Span tag. I want to change its behavior to a Div.

Is it possible to do this by simply applying the following CSS class to
the span tag:

..MySpan {display:block}

Thanks,
Miguel

Dec 28 '06 #1
7 2303
In article
<11**********************@73g2000cwn.googlegroups. com>,
"shapper" <md*****@gmail.comwrote:
Hello,

I have Span tag. I want to change its behavior to a Div.

Is it possible to do this by simply applying the following CSS class to
the span tag:

.MySpan {display:block}

I want to be first to get this in: why would you want to do this?

--
dorayme
Dec 28 '06 #2
Because I am using ASP.NET and it wraps user controls inside span tags.
I would like the wrapper to behave as a div.

Thanks,
Miguel
dorayme wrote:
In article
<11**********************@73g2000cwn.googlegroups. com>,
"shapper" <md*****@gmail.comwrote:
Hello,

I have Span tag. I want to change its behavior to a Div.

Is it possible to do this by simply applying the following CSS class to
the span tag:

.MySpan {display:block}


I want to be first to get this in: why would you want to do this?

--
dorayme
Dec 28 '06 #3

shapper wrote:
I have Span tag. I want to change its behavior to a Div.
It has two behaviours. One is from the HTML DTD (the nesting rules for
elements) You can't change this.

The other is for how it's displayed. This is controllable by CSS, just
as you describe.

You can make a <spandisplay like a block, but you still can't put a
<pinside it.

Dec 28 '06 #4

Andy Dingley wrote:
shapper wrote:
I have Span tag. I want to change its behavior to a Div.

It has two behaviours. One is from the HTML DTD (the nesting rules for
elements) You can't change this.
Where can I find some information on nesting rules?

Can I include a <divinside a <span>?

Thanks,
Miguel
>
The other is for how it's displayed. This is controllable by CSS, just
as you describe.

You can make a <spandisplay like a block, but you still can't put a
<pinside it.
Dec 28 '06 #5

shapper wrote:
Where can I find some information on nesting rules?
http://www.w3.org/TR/html4/sgml/dtd.html

Not the easiest thing to learn to read though! (search for "DTD
introduction" or something)
Can I include a <divinside a <span>?
No. Here's a small snippet of the DTD

<!--
HTML has two basic content models:

%inline; character level elements and text strings
%block; block-like elements e.g. paragraphs and lists
-->
Actually there's a third one too %flow;, which comprises both %inline;
and %block; elements
<!-- %inline; covers inline or "text-level" elements -->
<!ENTITY % special
"A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">

<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; |
%formctrl;">

So we see from this that <spanis one member of %inline; and also of
%flow; (see below)

<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">

<!ENTITY % flow "%block; | %inline;">

We see here that <divis one member of %block; and thus of %flow; but
NOT %inline;
<!ELEMENT SPAN - - (%inline;)* >

<!ELEMENT DIV - - (%flow;)* >

<spancan contain anything from %inline;
<divcan contain anything from %block; or %inline;

So <divcan contain <span>, but <spancan't contain <div>

Now see if you can read the DTD yourself and see where <pfits into
all this.

Dec 28 '06 #6
shapper wrote...
>
Where can I find some information on nesting rules?

Can I include a <divinside a <span>?
No.

A div is a block-line element whereas a span is an in-line element.
You can put an in-line element inside a block-line element, but not the
other way around.

See http://www.cs.tut.fi/~jkorpela/html/nesting.html for an indication
of hierarchy of elements.

See http://htmldog.com/guides/htmlintermediate/spandiv/ for more about
spans and divs.
--
Martin Clark
Dec 28 '06 #7
P.S. Hint: Learn how to quote on Usenet, or stay tuned to be ignored in
future.

That would be odd. Why don't you fix the way the markup is generated.

So do you really want your page work the intended way only when CSS is
enabled?
Because I am using ASP.NET and it wraps user controls inside span
tags. I would like the wrapper to behave as a div.
Scripsit shapper:

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Dec 30 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by deko | last post: by
reply views Thread by Xiaolei Li | last post: by
2 posts views Thread by FrankIsHere | last post: by
5 posts views Thread by ste.paoletti | last post: by
4 posts views Thread by hawat.thufir | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.