Page 1 of 1

<SPAN>s! Why do we need Spans?

Posted: Thu Sep 15, 2005 8:37 am
by pilau
Why do we need <spans>? What're the really useful and practicall implementations of spans?

Posted: Thu Sep 15, 2005 8:49 am
by hawleyjr
How would you do this using CSS?

Hello World, my name is James

Code: Select all

.divex{
color:red;
}
.divexname{
color: green;
}
<div id="mytitle" class="divex">Hello World, my name is <span class="divexname">James</span></div>

Posted: Thu Sep 15, 2005 8:50 am
by pilau
hawleyjr wrote:How would you do this using CSS?

Hello World, my name is James
<font> tag

Posted: Thu Sep 15, 2005 8:51 am
by hawleyjr
Not using the font tag using CSS.

Posted: Thu Sep 15, 2005 8:51 am
by pilau
Why not?

Posted: Thu Sep 15, 2005 8:55 am
by Roja
pilau wrote:Why not?
Font has been depreciated in XHTML and HTML strict. Ain't no such beast no more.

Styling should be done in Stylesheets, not in HTML - which is data/text, NOT formatting.

Posted: Thu Sep 15, 2005 8:55 am
by JayBird
font tag is old skool 8)

It was pretty good in 1995

Posted: Thu Sep 15, 2005 9:13 am
by CoderGoblin
In old HTML everything was a mix between structure information and presentation. Using CSS we are trying to break this apart. You have your structure produced possibly through PHP and you have you presentation information based, hopefully on CSS. To make this clearer the <font> tag was deprecated (should no longer be used) after all "font" implies text formatting when css can be far more.

<DIV> is used as a block element.
<SPAN> is used as an inline element.

You must bear in mind that different formats (print, web, speech) may each use a different style sheet. If using speech you would not use a "font". Using this approach <b>,<strong> and <i> tags should also never be used. <span class="important"> or <span class="indexed"> means that things are far more flexible if you need to produce different presentation methodologies.

Posted: Thu Sep 15, 2005 9:15 am
by pilau
And that's all for today's "Why spans are good?", kids!