Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / December 2006



Tip: Looking for answers? Try searching our database.

Transform a Span into a Div

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 28 Dec 2006 01:52 GMT
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
dorayme - 28 Dec 2006 02:11 GMT
In article
<1167270772.534976.260550@73g2000cwn.googlegroups.com>,

> Hello,
>
[quoted text clipped - 4 lines]
>
> .MySpan {display:block}

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

Signature

dorayme

shapper - 28 Dec 2006 02:48 GMT
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

> In article
> <1167270772.534976.260550@73g2000cwn.googlegroups.com>,
[quoted text clipped - 9 lines]
>
> I want to be first to get this in: why would you want to do this?
Jukka K. Korpela - 30 Dec 2006 18:32 GMT
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:

Signature

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

Andy Dingley - 28 Dec 2006 03:03 GMT
> 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 <span> display like a block, but you still can't put a
<p> inside it.
shapper - 28 Dec 2006 12:57 GMT
> > 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 <div> inside 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 <span> display like a block, but you still can't put a
> <p> inside it.
Andy Dingley - 28 Dec 2006 14:31 GMT
> 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 <div> inside 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 <span> is 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 <div> is one member of %block; and thus of %flow; but
NOT %inline;

<!ELEMENT SPAN - - (%inline;)*  >

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

<span> can contain anything from %inline;
<div> can contain anything from %block; or %inline;

So <div> can contain <span>, but <span> can't contain <div>

Now see if you can read the DTD yourself and see where <p> fits into
all this.
Martin Clark - 28 Dec 2006 14:32 GMT
shapper wrote...

>Where can I find some information on nesting rules?
>
>Can I include a <div> inside 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.
Signature

Martin Clark

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.