SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xHTML1.1 equivalent of <font> tag

    According to w3c the <font> tag is deprecated.
    So which is the substitute ? Im making my page in xHTML 1.1 and w3c's validator showed <font> as an error.

    Thanks
    Anjanesh

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use CSS.

    (X)HTML et al. is for marking up structure and semantics.
    CSS is for controlling presentation.
    ECMAScript + DOM (a.k.a. JavaScript) is for controlling behaviour.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I replaced <font> with <span> and it didnt show any errors.
    Anjanesh

  4. #4
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <span> is just the tag, but the font-style and all those things you can apply within the <font> tag (bold, italic,...) needs to be now as css.

    <span> might be even redundant. e.g if you want to apply the same font-size to a paragraph, ...

    Tell us more about what you want to achieve, than we can give you more practical advice. Or just have a look at:

    http://www.htmldog.com/guides/cssbeginner/

  5. #5
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Part of the reason <font> tags are not recommended is because they're a pain in the butt to update and work with. Just because it's valid, doesn't make it any better than <font> tags. I seriously recommend you get a book on CSS and see why it's the way to go and it's advantages over the old ways.

    Why the heck would one use 200 span tags on a page to set the same font for everything when you can just do it once, for the whole site, in an external stylesheet?
    Code:
    body {
    font: 11px Trebuchet MS, Verdana, sans-serif;
    }

  6. #6
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)

  7. #7
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tell us more about what you want to achieve, than we can give you more practical advice
    All I wanted was to have a small portion os a text (which is inside <td></td>) coloured. Thats all.
    Anjanesh

  8. #8
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .specialtext {
    font: 11px Trebuchet MS, Verdana,sans-serif;
    color: #666699; /*change color of text to suit*/
    }

    and apply that style to either the td or the text itself.

    Nadia

  9. #9
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's wrong with the FONT element?

    Using external CSS files can allow you to change the look of an entire site, just by editing the few CSS files.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  10. #10
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But dont we need some tag to apply these styles to that highlighted text ? I just need an xHTML 1.1 valid tag. <font> was'nt xHTML 1.1 complaint but <span> was.

    My lines are like : (after PHP generated the HTML equivalent)
    Code:
    <td>Sample Text Sample Text Sample <span style="color:red">Search Text</span> Text Sample Text Sample Text</td>
    Before I had font instead of span.
    Anjanesh

  11. #11
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your example, using span is fine. But for example if you would like to have the whole <td> to be of the same color, then you just apply the style to this tag:

    Code:
    <td style="color:red">Sample Text Sample Text Sample</td>
    You could still improve this and create a class called red, this comes in the style part which is either within the <head> or even better in an external stylesheet file:
    Code:
    .red {
        color:red;
    }
    And now applied like this:
    Code:
    <td class="red">Sample Text</td>
    <td>Sample Text <span class="red">Sample Text</span>Sample Text</td>
    If this is too complicated, I recommend to have a look at the link I posted above and learn more about CSS.

  12. #12
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    UK, London
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is also quite clever not to call a class what it looks like. Classes should define how a certain repeating page element looks like, it is not paint :-)

    .warning for example or .specialoffer . If in a redesign or whitelabelling .red has to become blue, maintenance becomes a nightmare.
    Chris Heilmann
    Blog | Articles | Binaries

  13. #13
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by codepoet
    It is also quite clever not to call a class what it looks like. Classes should define how a certain repeating page element looks like, it is not paint :-)

    .warning for example or .specialoffer . If in a redesign or whitelabelling .red has to become blue, maintenance becomes a nightmare.
    Of course, you are right. A class should get a descriptive name. I was just too tired...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •