[html5] What replaces <tt> in HTML5?

Benjamin Hawkes-Lewis bhawkeslewis at googlemail.com
Tue Apr 28 11:38:21 PDT 2009

On 28/4/09 19:00, Jim Garrison wrote:
> I am trying to figure out the best way to replace<tt>  as I migrate to
> HTML5.
> The best I can come up with so far is:
>      <span class="tt">Text here</span>
> with the corresponding CSS:
>      .tt { font-family: monospace; }
> Is this truly the only way to do what I want?

If this is purely a stylistic effect then, yes, CSS is the way to go, 
though if you can work out what semantics you're trying to communicate 
with this styling (if any) there may be a more appropriate element than 
"span" and/or a more presentation-independent class name than "tt". e.g. 
the "code" element, or the "user-interface-label" class name.


> Ideally I would like to be able to say "give me the most appropriate
> monospace font considering the current font-family in use" instead of
> "give me the default monospace font on the system."

I don't understand. Why not specify more font families in your 
font-family value?


>  (Just as, for
> instance, the<b>  element uses the best bold font based on the current
> font family)

That's not what "b" means. ("b" doesn't necessarily get styled bold by 
the user agent - that's just a common styling in GUI browsers.)

Benjamin Hawkes-Lewis

More information about the Help mailing list