How can I use CSS to make text superscript, or subscript?
Karls
Subscript and Superscript
Hi Karls,
You could define styles for a span to look like superscript or subscript.
.superscript{font-size:xx-small; vertical-align:top;}
.subscript{font-size:xx-small; vertical-align:bottom;}
<span class="subscript"> Hope that helps[/code]
Subscript and Superscript
Cool,
Will try it out now, thanks.
Karl 
Subscript and Superscript
There's also the <sup> tag, and vertical-align:super. So many options, so little time... :roll:
Subscript and Superscript
There's also the <sup> tag, and vertical-align:super. So many options, so little time... :roll:
hello there, ladies and gentlemen.
is there a general concensus on which technique is best used for a superscript? w/out trying any yet, my guess is that Sven's CSS suggestion is intended to work for any font size at that given section where the superscript rule is applied (in other words, if the font is large, and {vertical-align: super; } is used, the superscript would be smaller than the neighboring text). am i correct?
and my guess is that Tony's example is more "guaranteed" to work in any situation.
now, what about the <sup>? is that an html tag? if so, can we count on it being deprecated?
(can you tell i didn't do any research before posting?) I hope that my inquiry might help the next person as well.
Subscript and Superscript
now, what about the <sup>? is that an html tag? if so, can we count on it being deprecated?
Personally, I don't see anything wrong with using the <sup> and <sub> tags and adjusting them with css...they do seem semantic to me. :oops:
Subscript and Superscript
Uh, maybe I'm wrong. They are listed as being presentational and "should be avoided". :oops:
http://www.htmldog.com/reference/htmltags/presentational/
Dunno if I agree with that. On the page you've linked to, there's another link to the 'bad tags' page with explanations as to why they're bad but <sup> and <sub> don't appear there. For the tags they have given an explanation for, it's usually that there's an alternative (e.g. <strong> for < b > and <em> for < i >), but there's no alernative for <sup> and <sub> and it seems to me that to get a similar presentation using CSS is over-engineering it.
And superscript & subscript aren't just small numbers - they actually have their own meaning which it seems to me you couldn't adequately convey using just CSS.
Subscript and Superscript
Wow talk about trawling up old threads!
The sub and sup tags are valid and not deprecated and do indeed convey their own semantic meaning, to just use CSS to convey that styling would be just that styling and would have no meaning as such.
Aproach it the same way as you might for the use of an em tg where you can use CSS to style the presentation of the tag to your requirements but you still make a choice to use that tag with it's conveyed meaning in the actual HTML markup, a page rendered sans styling still conveys the intention of that section of the markup through the use of the em tag or in this case sub and sup tags.
As Tyssen says they are not just small numbers.
On a side note we ought to be careful with the somewhat unfounded beliefe that em/strong are replacements for i/b as this is not strictly true I and B still have a purpose and are not deprecated.
Hugo.
Subscript and Superscript
Triumph wrote:Uh, maybe I'm wrong. They are listed as being presentational and "should be avoided". :oops:
http://www.htmldog.com/reference/htmltags/presentational/
Dunno if I agree with that.
Sorry about any confusion. I do think the tags have a place and are useful and semantic.
Wow talk about trawling up old threads!
Subscript and Superscript
Huh? Who's this Sven?
His last post was 6 months ago, and before that, his last post was Jan 04.
Strange . . . .
Subscript and Superscript
TPH judging by Svens joined date and the forum inception date I would think that Sven was one of the first and original members and possibly a friend of Tony's, given that they both hail from the same town and that the joined dates are the same
.
Subscript and Superscript
I've never seen Tony and Sven in the same room at the same time...maybe they are the same person. Sven is like Clark Kent to Tony's Superman. I know it!!! 
Subscript and Superscript
Are yes Tony was employing the multiple identity trick for new forums
Subscript and Superscript
Actually Sven is a friend of mine whom I used to work with at about the time I started this forum.
He later found another job which involved less or no web work and has since had his first child.
As you can understand peoples lives and priorities change.
He wasn't one of my multiple identities, used only for testing :roll:
Back to the topic personally I think using the tags gives semantic meaning to the content.
So perhaps a combination of the sup tags and css to style it would be the way to go.
Subscript and Superscript
Sorry didn't mean to infer any multiple personality disorder
So perhaps a combination of the sup tags and css to style it would be the way to go
That would be my take on it.
Hugo.
Subscript and Superscript
Of course - you use <h1> tags for headings, and <div> tags to divide the page up - why not use the <sup> tag to imply superscript text?
Subscript and Superscript
So, I wasn't wrong? 
I guess I just doubted myself after reading that article.
Subscript and Superscript
Regarding the sub/sup/css thing:
I sometimes get annoyed by the <sup> tags way of making extra linespace between the tag and the overlying row. I thought about using styled spans instead of <sup>, but then i styled <sup> like this:
sup {
vertical-align: baseline;
font-size: 0.8em;
position: relative;
top: -0.4em;
}
Preserves the line-height, gives me more typographic control, and keeps everything semantic. Seems to work cross-browser.
Subscript and Superscript
Regarding the sub/sup/css thing:
I sometimes get annoyed by the <sup> tags way of making extra linespace between the tag and the overlying row. I thought about using styled spans instead of <sup>, but then i styled <sup> like this:
sup {
vertical-align: baseline;
font-size: 0.8em;
position: relative;
top: -0.4em;
}
Preserves the line-height, gives me more typographic control, and keeps everything semantic. Seems to work cross-browser.Nice. I am using it from now on. 
superscript
hi the css should look like this i think
font-size: xx-small;
vertical-align: text-top;
s4ndp4pper wrote:Regarding
Regarding the sub/sup/css thing:
sup {
vertical-align: baseline;
font-size: 0.8em;
position: relative;
top: -0.4em;
}
I use a fixed-width font in a few places. and both screw up the width so I added
margin-right: 0.125em;
It may not be mathematically perfect but works for me. Thanks for the code.
Hmmm, I'm going to break
Hmmm, I'm going to break etiquette and post this in both forums:
sup makes sense for math and chemistry and citations, but is it the right tag for ordinals? Esp, say, Dutch ordinals? I'm currently using them inside abbr tags but not sure if there's a better tag for this.
Well, despite the fact
Well, despite the fact drifter1 dragged up a 3 year old thread, I'll post this site I found last year when I had the need and in case it helps someone else.
Five versions of superscripted endnotes/footnotes with demos, code, advantages and disadvantages of each. Enjoy! 
Oh wow Smee, thanks! Looks
Oh wow Smee, thanks! Looks like a nice site... might end up bookmarking it.









