What is best replacement for in CSS?

后端 未结 3 922
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 15:07

I am working on updating an old website which uses font tags, to use CSS. The old HTML uses numeric font sizes (1-7) like this:

Some text         


        
相关标签:
3条回答
  • 2021-02-05 15:27

    There is no defined mapping in approved specifications. HTML specifications do not say that what the values in <font size=...> mean; they are just a browser-dependent scale of sizes (and could all map to a single size). Similarly, CSS specifications do not define the meanings of font-size keyword values as absolute sizes or in HTML terms.

    HTML5 CR, which is work in progress, suggests a specific mapping, except that it does not define the CSS counterpart of xxx-large; it just describes it as being a value that “is a non-CSS value used here to indicate a font size 50% larger than 'xx-large'”.

    It is generally not useful to look for the mapping. For legacy pages, which might rely on some specific values for font size, just let them be. There is no point in trying to modernize them, e.g. by switching from presentational HTML to CSS. For new pages, the crucial question is what font sizes suit your needs, and for them, you had better forget <font size> entirely.

    0 讨论(0)
  • 2021-02-05 15:51

    from W3C

    http://www.w3.org/TR/html4/present/graphics.html#edef-FONT

    size = cdata [CN] Deprecated.

    This attribute sets the size of the font. Possible values:

    • An integer between 1 and 7. This sets the font to some fixed size, whose rendering depends on the user agent. Not all user agents may
      render all seven sizes.
    • A relative increase in font size. The value "+1" means one size larger. The value "-3" means three sizes smaller. All sizes belong to the scale of 1 to 7.

    front this peice you could clearly see that equivalent to size will be large or x-large .. etc

    explanation :

    <font size="3"> is just as if you used font-size: medium ;

    <font size="4"> is just as if you used font-size: large ;

    <font size="5"> is just as if you used font-size: x-large ;

    <font size="6"> is just as if you used font-size: xx-large ;

    <font size="7"> is just as if you used font-size: -webkit-xxx-large;


    update :

    i think i have got it wrong the first time it's not em's (although they work similarly). please see the update :)

    0 讨论(0)
  • 2021-02-05 15:51

    xx-small, x-small, small, medium, large, x-large, xx-large A set of absolute size keywords based on the user's default font size (which is medium). Similar to presentational HTML's through where the user's default font size is .

    /* <absolute-size> values */
    font-size: xx-small  
    font-size: x-small /* <font size="1"> */
    font-size: small /* <font size="2"> */
    font-size: medium /* <font size="3"> */
    font-size: large /* <font size="4"> */
    font-size: x-large /* <font size="5"> */
    font-size: xx-large /* <font size="6"> */
    font-size: -webkit-xxx-large; /* <font size="7"> */
    

    Reference

    • CSS font-size - Mozilla Development: https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
    0 讨论(0)
提交回复
热议问题