navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Proper use of <span>

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Cascading Style Sheets >> Proper use of <span>
Page: [1]
 
hzarabet

 

Posts: 1539
From: New Milford CT USA
Status: offline

 
Proper use of <span> - 4/29/2004 14:09:02   
Hi all...

I am trying to use <span> when I want a small bit of text to fall outside of the class it is already in. I am not having much luck...

Here is a test page...

<body>

This is a <span class="centers">test</span>


</body>


This is from my style sheet:


BODY {
background: white;
color: black;
margin : 0;
padding-right: 2px;
text-align: left;
height: 30px;
font-size: 100%;
font-weight: 400;
font-family: arial, helvetica, sans-serif;
margin-left: 6px;
margin-right: 1px;
margin-top: 10px;
vertical-align: top;
}

.centers {
text-align: center;
}

What am I doing wrong with <span>?

_____________________________

http://www.SigningsHotline.com lists EVERY upcoming athlete autograph appearance in the US and Canada
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Proper use of <span> - 4/29/2004 16:04:44   
text-align: center applies to block level elements or a single span, but obviously you can centre align a single word within a left aligned block of text!

_____________________________

David Prescott
Gekko web design

(in reply to hzarabet)
c1sissy

 

Posts: 5084
Joined: 7/20/2002
From: NJ
Status: offline

 
RE: Proper use of <span> - 4/29/2004 16:07:36   
Dave, can't word spacing be used somehow? Just curious.

_____________________________

Deb-aka-c4Ksissy
high panjandurum and alpha female of the silverback tribe
As decreed by Jesper 5-24-2003.
The only stupid question is... the one that is never asked!!
http://directory.css-styling.com
http://fmsforum.com
http://positioniseverything.net/
http://www.tanfa.co.uk/

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Proper use of <span> - 4/29/2004 16:10:01   
you mean if you wanted one word (or several) in a paragraph to have different word spacing? yes, but that er applies to words. (or paragraphs)

_____________________________

David Prescott
Gekko web design

(in reply to c1sissy)
c1sissy

 

Posts: 5084
Joined: 7/20/2002
From: NJ
Status: offline

 
RE: Proper use of <span> - 4/29/2004 16:30:43   
quote:

.centers {
text-align: center;
}

and
quote:

This is a <span class="centers">test</span>


From what he is showing here he wants the word test to be centered. Couldn't you use word spacing and mess with the values to achieve this? If you place the word spacing right in between with the span? I know I had seen this done somewhere in all of my reading.

Now I'm really curious and am going to do a search

I found something, could he do this?
.center {word-spacing: 1em;}
then
<span class="center">test</span>

< Message edited by c1sissy -- 4/29/2004 16:34:57 >


_____________________________

Deb-aka-c4Ksissy
high panjandurum and alpha female of the silverback tribe
As decreed by Jesper 5-24-2003.
The only stupid question is... the one that is never asked!!
http://directory.css-styling.com
http://fmsforum.com
http://positioniseverything.net/
http://www.tanfa.co.uk/

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Proper use of <span> - 4/29/2004 16:35:43   
don't know if it helps but see
http://members.surfeu.fi/dave_pirjo/test-area/css_stuff/span.html (view source code for css)

text-align:center centres text, but not if it's in the middle of a leftaligned paragraph.
word spacing is the space in between words.

_____________________________

David Prescott
Gekko web design

(in reply to c1sissy)
c1sissy

 

Posts: 5084
Joined: 7/20/2002
From: NJ
Status: offline

 
RE: Proper use of <span> - 4/29/2004 16:59:38   
quote:

text-align:center centres text, but not if it's in the middle of a leftaligned paragraph.
word spacing is the space in between words.


Right, I understand that text-align center and how it works.

Since the word appears to be in the middle of a sentence, as indicated by his sentence in his post, if a class was used, by using the word space, which causes spaces between words wouldn't this work? He could play with the value and try to get the word centered in a way that he wants to.

Oh, going to the link now to view it!

< Message edited by c1sissy -- 4/29/2004 17:03:33 >


_____________________________

Deb-aka-c4Ksissy
high panjandurum and alpha female of the silverback tribe
As decreed by Jesper 5-24-2003.
The only stupid question is... the one that is never asked!!
http://directory.css-styling.com
http://fmsforum.com
http://positioniseverything.net/
http://www.tanfa.co.uk/

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:06:32   
it is a class, but whatever if you center align a word in a paragraph (if it's possible by any means) how are you going to see it? the sentence i've just typed could contain a centred word but it would be sanwiched between adjacent leftaligned words so you can't tell the difference.

_____________________________

David Prescott
Gekko web design

(in reply to c1sissy)
c1sissy

 

Posts: 5084
Joined: 7/20/2002
From: NJ
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:12:25   
But dave, I"m not using the center align at all. What I am trying to say is use word spacing, this way he can get the word to appear as he wishes in the sentence. So if he wants test to appear as such, then use word spacing. Follow me?

<edit> word spacing wont work, I just tried it out. </edit>
<edit again> How about the use of the pre element?
http://www.blooberry.com/indexdot/html/tagpages/p/pre.htm
</edit>

< Message edited by c1sissy -- 4/29/2004 17:24:56 >


_____________________________

Deb-aka-c4Ksissy
high panjandurum and alpha female of the silverback tribe
As decreed by Jesper 5-24-2003.
The only stupid question is... the one that is never asked!!
http://directory.css-styling.com
http://fmsforum.com
http://positioniseverything.net/
http://www.tanfa.co.uk/

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:20:47   
aargh! no not at all! word spacing increases the space between *words* not within words so if you only have one word it doesn't make any difference.

Doesn't the 'warning' example in my link make sense? applying a class (warning) to a span to produce an eddect in one word in styled sentence??

i'm trying to understand... ;)

_____________________________

David Prescott
Gekko web design

(in reply to c1sissy)
c1sissy

 

Posts: 5084
Joined: 7/20/2002
From: NJ
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:27:32   
quote:

i'm trying to understand... ;)


LOL so am I! I sent you a pm.

<pre>This is a        test       to see if this makes sense</pre>


this is what I was wondering if she could do with the word spacing, but with pre, if this is what she is after, this might work!

< Message edited by c1sissy -- 4/29/2004 17:54:11 >


_____________________________

Deb-aka-c4Ksissy
high panjandurum and alpha female of the silverback tribe
As decreed by Jesper 5-24-2003.
The only stupid question is... the one that is never asked!!
http://directory.css-styling.com
http://fmsforum.com
http://positioniseverything.net/
http://www.tanfa.co.uk/

(in reply to d a v e)
jaybee

 

Posts: 14157
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:35:52   
I'm sorry guys but I've read this over and over and I fail to see how you can centre a single word if it's in the middle of a sentence.

If it's just the word Test on it's own in a table cell for example then fine.

I think the point here is that it's fine using span to make a word in a sentence bold or pink or whatever but you're wasting your time trying to centre it.

The code that hzarabet has posted works fine for a single word. It sticks it in the middle of the body.

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to d a v e)
jaybee

 

Posts: 14157
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:37:39   
Hzarabet,

can you post an example of what you want your output to look like, then we can tell you what code to use.

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to jaybee)
c1sissy

 

Posts: 5084
Joined: 7/20/2002
From: NJ
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:40:23   
quote:

but you're wasting your time trying to centre it.


LOL does it hurt to try?:):):)

_____________________________

Deb-aka-c4Ksissy
high panjandurum and alpha female of the silverback tribe
As decreed by Jesper 5-24-2003.
The only stupid question is... the one that is never asked!!
http://directory.css-styling.com
http://fmsforum.com
http://positioniseverything.net/
http://www.tanfa.co.uk/

(in reply to jaybee)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:41:27   
yep we've moved on from there (eventually! ;)

it's similar thing for word spacing - you need more than one word and it applies to block level (i.e. paragraph, div whatever elements)

to get sissy's effect you could make a style
.spaced {padding-left:10px; padding-right:15px;} and apply it to a span

This is a <span class="spaced">test </span> to see if this makes sense

_____________________________

David Prescott
Gekko web design

(in reply to jaybee)
jaybee

 

Posts: 14157
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: Proper use of <span> - 4/29/2004 17:45:09   
quote:

LOL does it hurt to try?


That depends........ if you end up banging your head on the desk then..... probably. :)

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to d a v e)
hzarabet

 

Posts: 1539
From: New Milford CT USA
Status: offline

 
RE: Proper use of <span> - 4/29/2004 23:10:52   
Here is another span problem. I want to center the text and input box/button for this form, but it is still aligning left per the td class:

<span class="center">
<form name="Subscribe" method="post" action="http://www.signingshotline.com/maillistXL/mailinglist.asp">
<input type="hidden" name="L" value="1" />
<input type="hidden" name="format" value="H" />
<input type="hidden" name="a" value="s" />
Enter your email address in the box below and press subscribe to enter  
<input type="text" name="Email" size="12" />
<input type="hidden" name="Action" value="Subscribe" />
<input type="hidden" name="Confirmed" value="yes" />
<input type="submit" name="Subscribe" value="Subscribe" />
</form>
</span>

No matter what I try...it will NOT align center.

I am beginning to think CSS actually stands for C**** S****** S***

< Message edited by hzarabet -- 4/29/2004 23:33:41 >


_____________________________

http://www.SigningsHotline.com lists EVERY upcoming athlete autograph appearance in the US and Canada

(in reply to hzarabet)
gorilla

 

Posts: 2974
From: Denmark
Status: offline

 
RE: Proper use of <span> - 4/29/2004 23:23:42   
It is 5.05 AM here in Copenhagen as I type this. Which means btw that I have now been up slightly more than an hour.

I've a mountain of work to get through but nevertheless - Hrzabet email me would you sending all the code as an attachment and I'll step through it with you over the weekend.


In fact hrazabet please edit how you fixed it out of your posting would you?

< Message edited by c1sissy -- 4/30/2004 16:56:09 >


_____________________________

Mháircaish

Signature self-censored to protect the sensibilities of the thin-skinned :).

May we never confuse honest dissent with disloyal subversion. – Dwight D. Eisenhower



(in reply to hzarabet)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Proper use of <span> - 4/30/2004 1:25:31   
managed to get one word centred in a paragraph of left aligned text AND increased the word spacing on a single word (very zen) BUT here's the caveat:
it only worked when i was having nightmares about it last night:)

_____________________________

David Prescott
Gekko web design
Page:   [1]

All Forums >> Web Development >> Cascading Style Sheets >> Proper use of <span>
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts