SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict Scott Blanchard's Avatar
    Join Date
    Sep 2010
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Specifying multi-word font families in css

    I've seen multi-word font families encapsulated with single quotes, double quotes and no quotes.

    Are there browser compatibility issues with any of the above?

    Example:

    No Quotes:
    font-family:Lucida Sans Unicode, Lucida Grande, sans-serif;

    Single Quotes:
    font-family:'Lucida Sans Unicode', Lucida Grande', sans-serif;

    Double Quotes:
    font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;

    Mixed:
    font-family:"Lucida Sans Unicode", Lucida Grande, sans-serif;

  2. #2
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    font-family (CSS property)

    Essentially, you can do whatever you want, though it's best to put it in double-quotation marks.

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,877
    Mentioned
    160 Post(s)
    Tagged
    4 Thread(s)
    These paragraphs from the link samanime gave above should clarify the situation a little:

    The values are either font family names or generic family names. Font family names are quoted or unquoted strings, while generic family names are keywords and shouldn’t be quoted.
    It’s a good idea to quote any font family name that contains spaces or other non-alphanumeric characters. Special characters must be escaped if the value isn’t quoted. Whitespace characters will be ignored at the beginning or end of an unquoted name, and multiple white space characters inside the name will collapse to a single space.
    Also, if a font family name happens to be the same as a generic family name or any other CSS keyword, it must be quoted to avoid confusion.

  4. #4
    SitePoint Addict Scott Blanchard's Avatar
    Join Date
    Sep 2010
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys. I appreciate the references and explanation. It appears that its more a recommendation than a rule. However, no specifics on single vs double quotes, so I suppose that doesn't matter.

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,877
    Mentioned
    160 Post(s)
    Tagged
    4 Thread(s)
    Either/or are fine as long as they are correctly matched.

  6. #6
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Scott Blanchard View Post
    Double Quotes:
    font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
    This is the way I do it. Not saying my way is by definition correct, but from the research and reading I've done, this is considered "best practices."


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
  •