tags:

views:

405

answers:

3

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">
      <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>
A: 

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?

JasCav
hi, i tried pressing ctrl+0 multiple times..but it's still big. weird.
ShaChris23
+8  A: 
<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.)

bobince
thank you for the detailed answer!
ShaChris23
agreed. if you're using XSLT to output HTML, use CSS.
carillonator
+1 Wow...I'm a noob. Can't believe I missed that. Good call.
JasCav
+1 for the content of the aside
Lord Torgamus
A: 

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"&gt;

    <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>
ShaChris23
Strange how you *not* wanted to use CSS and now you are doing it anyway. ;-)
Tomalak
@Tomalak: lol..you are right. What I meant by not use CSS was that I could not have a separate .css file (this is a school assignment and they told us we cannot have a separate file...go figure)
ShaChris23
You don't need an external CSS file :) You could move all the styling into the <head> of the document by adding a <style> element: <style type="text/css">table { background: yellow; }th, td { font-size: 14pt; font-family: sans-serif; }</style>. Also note you don't need the remianing font tags either - style="font-size: 14pt; font-family: sans-serif;" would achieve the same thing.
Olly Hodgson