<SPAN>s! Why do we need Spans?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

<SPAN>s! Why do we need Spans?

Post by pilau »

Why do we need <spans>? What're the really useful and practicall implementations of spans?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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>
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

hawleyjr wrote:How would you do this using CSS?

Hello World, my name is James
<font> tag
Last edited by pilau on Thu Sep 15, 2005 8:51 am, edited 1 time in total.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Not using the font tag using CSS.
Last edited by hawleyjr on Thu Sep 15, 2005 9:10 am, edited 1 time in total.
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Why not?
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

font tag is old skool 8)

It was pretty good in 1995
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Last edited by CoderGoblin on Thu Sep 15, 2005 9:15 am, edited 1 time in total.
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

And that's all for today's "Why spans are good?", kids!
Post Reply