CSS Help
- Started
- Last post
- 14 Responses
- Mick
Any way I can align a span of text to the right of a td with CSS?
eg.
This is some text (span align="right")this is to the right of the table cell(/span)
- Mick0
I did it with a DIV but it adds a line break witht he alignment.
- spk0
some text
?
- Mick0
come again?
- cinder0
this does it for all of em:
td {
text-align: right;
}or make a class
td.rightside {
text-align: right;
}and then
[td class="rightside"]
that might work
- jevad0
what cinder said
- Mick0
But I don't want the whole TD contents to align right - just a portion of the text.
So I can do
Dog $350
Cat $150
etc.
- jevad0
stick the text that you do want to align into a span then, and give it a class that aligns the text right
- sparker0
it sounds like it's tabular data, why not just create more column/row sets to support the data?
if you're going to use a table, use the table, if you want to build it without a table, then do it with divs, spans and css.
but, like i said above, it sounds like the content you are trying to display is tabular in nature.
it is ok to make a table for that.
is there a reason why you can't make multiple columns and rows?
- davetufts0
spans are inline CSS elments and can not be aligned. You'll need to use a block element such as div or [p].
but like the guy before said, just use a table
- SF0
Yes, table is best. CSS as great as it is, does have limitations that tables can fix. It still validates as XHTML, so theres no worries there.
- sparker0
"Yes, table is best. CSS as great as it is, does have limitations that tables can fix. It still validates as XHTML, so theres no worries there."
it's not that css and xhtml can't "fix" something that tables can...this is an issue of correct usage.
in this case, it is correct to use a table - since the data presentation is in tabular (ie, spreadsheet) form.
valid, accessible and standards compliant markup isn't about using exculsively css/xhtml over tables, it is about using things properly.
css and xhtml don't really have limitations anymore. it is all about usage and design.
you could easily build a "table" layout in xhtml using css without actual 'table' tags...but that wouldn't really be using markup and web design properlly.
and, xhtml/css isn't limited. browsers are limited.
:)
- mirola0
zeldman? is that you?
- SF0
Was thinking the same thing mirola.
But i think i was essentially trying to say the same thing as you Sparker. You just said it better.
I wasn't suggesting the table as a dodgy 'fix' though. CSS/XHTML IS limited when it comes to tabular data, in the sense that it is more efficient & therefore correct to use the table tags. Tables were initially put into HTML for that use, and they do it very well... even better when you control them with css.