2

这是我的 HTML 代码片段。我将每个文本的字体大小指定为 14,但是当我在 Firefox 上渲染它时,它看起来太大了!有没有更好的方法来指定字体大小?

注意:我想知道如何在 HTML 中做到这一点,而不是使用 CSS。

<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><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>
4

3 回答 3

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

哇!字体标签。好久没看到那些了!

字体大小HTML 属性不是以像素或点 (*) 为单位设置的绝对字体大小,它是相对于使用“4”获得的默认字体大小的“1-7”大小比例。设置大于 7 的尺寸是无效的,但通常会为您提供与“7”相同的超大尺寸。在所有浏览器中都会发生这种情况,而不仅仅是 Firefox。

今天几乎没有理由使用字体标签。XSLT 也没有什么可以阻止您使用 CSS,或者像字体标签一样内联:

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

或者,更具可读性,在样式表中:

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

(*:除此之外:除了打印样式表之外,不要使用点——CSSpt单元。在屏幕上它具有绝对像素的所有缺点,而且在某些平台上尺寸会出现额外错误。px用于固定字体大小和em/或%用于普通文本。)

于 2009-11-17T05:20:43.550 回答
0

我在您的代码中看不到任何明显的内容。您是否有可能在 Firefox 中增加了文本大小,以便只在浏览器中看到问题?

于 2009-11-17T04:58:58.077 回答
0

只是为了完整起见,这是使它适用于我的案例的最终代码(注意一切如何使用样式,并指定为 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>
于 2009-11-17T05:41:22.297 回答