Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS quotes in css?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35249
    cybershot
    Participant

    I see some css with quotes and some without. Is it optional? I don’t remember. Why put them if it works without? example


    background: url('images/myimage.png');

    or

    background: url(images/myimage.png);

    #90987

    It is personal preference, double quotes are also acceptable. Keep in mind that if there is a space separating two individual values then you need to wrap them in quotes:

    class=banner ribbon

    Is not equal to:

    class="banner ribbon" or class='banner ribbon'

    #90996
    WouterJ
    Member

    @Joshuan, that is in HTML. In HTML5 it is valid to use no quotes, but I recommend to use them. Because of the space problem.


    @Cybershot
    , in CSS there is no need to use quotes. But it has the same problem as in HTML, if there is a space you need to use de quote. Examples:

    font-family: 'Trebuchet MS', Verdana, sans-serif;
    /* Trebuchet MS needs quotes, because there is a space in the name */
    background: url('images/my image.png');
    /* There is a space => quotes (but in this case, I should remove the space in the name */
    background: url(images/myimage.png);
    /* No spaces, so we don't need to use quotes */
    #91009

    @WouterJ Perhaps I should have been clearer, HTML and CSS have the same behaviour in regards to quotes.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.