code-sign

Tuesday, January 03, 2006

Better CSS for subscripts

The standard mechanism for creating subscripts in HTML is with the sub tag. It bothers me that subscripts in HTML sometimes affect line height, so that lines with subscripts are more widely spaced than regular text. This is not a problem with, say, LaTeX.

Fortunately, there is an easy hack you can use to fix the broken tag: force the line height to zero.
sub {
line-height: 0;
}
And now you can have your subscripts, such as aij, with no problem.

1 Comments:

  • In my personal experience, simple line-height statement didn't solve the problems in all version if IE. You may want to add "vertical-align: text-top;" for better rendering.

    By Anonymous soxiam, at 1:05 PM  

Post a Comment

<< Home