Is quoting the value of url() really necessary?

后端 未结 7 2057
情话喂你
情话喂你 2020-11-22 09:40

Which of the following should I use in my stylesheets?

/* Example #1: */ background-image: url(image.png);
/* Example #2: */ background-image: url(\"image.pn         


        
7条回答
  •  误落风尘
    2020-11-22 10:34

    Example 2 or 3 are best:

    From W3C: The format of a URI value is 'url(' followed by optional white space followed by an optional single quote (') or double quote (") character followed by the URI itself, followed by an optional single quote (') or double quote (") character followed by optional white space followed by ')'. The two quote characters must be the same.

    Note from the same explanation, Example 1 is acceptable, if appropriate characters are escaped.

提交回复
热议问题