Forum Moderators: open

Message Too Old, No Replies

span class attribute

         

Geoffrey james

5:40 am on Nov 7, 2006 (gmt 0)

10+ Year Member



hi all.

I have a qoute at the top of my page and the name after the qoute needs to be aligned right.

Using external css:

.qoutename {
text-align: right;
}

then html

<span class="qoutename">
Toni Robbins
</span>

This lookes ok, but as soon as i preview it site over to the left again....WHY

geoff

seanbun

6:41 am on Nov 7, 2006 (gmt 0)

10+ Year Member



It is hard to tell by this incomplete code. but I suggest you can put a 1px border on the span container and you can see the width of your span container whether take all the space of the parent container's width.

.qoutename {
text-align: right;
border : 1px solid #333;
}

tedster

6:50 am on Nov 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you'll find that "text-align" rules apply to block level elements, but "span" is an inline element. If you use a block level element for the text you want to align to the right, such as <div class="qoutename"> it should work.

[w3.org...]

<added>
While using a block element such as <p> or <div> may give the results
that you want, the full story is actually a bit more complex than that. See:
[w3.org...]
</added>

Geoffrey james

3:00 pm on Nov 7, 2006 (gmt 0)

10+ Year Member



hi tedster,

Thanks for that. we are all stupid sometimes i suppose and remember hard coding, but forget some very basic rules of CSS.

cheers it's cool now.

geoff