开发者

HTML: Font size is too big - why?

Here's a snippet of my HTML code. I specify the font size for each text to be 14, but when I render it on Firefox, it looks so big! Is there a better way to specify the font size?

Note: I want to know how to do this in HTML, not using CSS.

<html>
  <head>
    <title>Clinics with H1N1 Flu Vaccine in Stock</title>
  </head>
  <body>
    <!-- BEG: Patient Group table -->
    <table border="2" bgcolor="yellow"&g开发者_运维知识库t;
      <tbody>   
        <tr>
          <th><font size="14" face="sans-serif">Group</font></th>
          <th><font size="14" face="sans-serif">Vaccine Quota</font></th>
        </tr>
      </tbody>
    </table>
  </body>
</html>


<font size="14" face="sans-serif">

Whoah! Font tags. Not seen those in a long time!

The font size HTML attribute is not an absolute font size set in pixels or points(*), it is a scale of sizes ‘1–7’ relative to the default font size which you get with ‘4’. Setting a larger size than 7 is invalid, but typically gives you the same extra-large size as ‘7’. This happens for me in all browsers, not just Firefox.

There is pretty much no reason to use the font tag today. There's nothing about XSLT that prevents you from using CSS as well, either inline like a font tag:

<th style="font-size: 90%; font-family: sans-serif;">Group</th>

or, much more readably, in a stylesheet:

table { background: yellow; }
th, td  { font-size: 90%; font-family: sans-serif; }

(*: aside: never use points — the CSS pt unit — for anything but print stylesheets. On-screen it has all the disadvantages of absolute pixels plus the size comes out extra-wrong on some platforms. Use px for fixed font sizes and em or % for normal text.)


I don't see anything obvious in your code. Is it possible that you increased your text size within Firefox so that you are only seeing the problem in your browser?


Just for completeness, here's the final code that got it working for my case (notice how everything uses style, and is specified with 14pt

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">

    <xsl:output method="html" />
    <xsl:template match="/Vaccination">
        <html>
            <head>
                <title>Clinics with H1N1 Flu Vaccine in Stock</title>
            </head>
            <body>

                <!-- BEG: Patient Group table -->
                <table border="2" bgcolor="yellow">
                    <tbody> 
                        <tr>
                            <th style="font-size: 14pt"><font face="sans-serif">Group</font></th>
                            <th style="font-size: 14pt"><font face="sans-serif">Vaccine Quota</font></th>
                        </tr>               
                        <xsl:for-each select="patient_group">
                            <tr>
                                <td style="font-size:14pt"><font face="sans-serif"><xsl:value-of select="Group" /></font></td>
                                <td style="font-size:14pt" align="center"><font face="sans-serif"><xsl:value-of select="Quota" /></font></td>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜