473,405 Members | 2,272 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,405 software developers and data experts.

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 2386
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: deko | last post by:
How to change a link's color based on a php variable? I have a number of links on a page: <p><a href="page1.php">Page 1</a></p> <p><a href="page2.php">Page 2</a></p> <p><a...
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...
0
by: Xiaolei Li | last post by:
first off, i'm a total newbie at this stuff so excuse any wrong usage of terminology or whatever else. i have a XSL to transform a Document such that all "text" nodes will have a "SPAN" inserted...
2
by: FrankIsHere | last post by:
I'm having some problems converting HTML to XML. Below is the source document. <html xmlns:wf="http://sometest/wf"> <head> <span wf:class="cookie.equals.EntryURL" wf:values="region">...
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: Tim Menninger | last post by:
When I use the XslTransform.Transform method to write to the HttpRequest.OutputStream The first byte of the output is always an invalid character, looks like an ascii zero or some other...
5
by: ste.paoletti | last post by:
I have a problem with css I have a this xhtml code: <span> <span> <span/> <input type="radio"/> .... <span/> <input type="button" onclick ="var s=document.createElement('span');...
2
by: ricky | last post by:
Hello, If anyone could help me with this I would highly appreciate it. I've tried everything and nothing works. What I am trying to do is so damn basic and it's just frustrating that it seems...
4
by: hawat.thufir | last post by:
Just for posterity: $ pwd /home/thufir/xalon/w3school $ whoami thufir $ ll total 24 -rw-rw-r-- 1 thufir thufir 239 Feb 19 09:16 foo.xml
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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
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,...
0
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...

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.