0

I have a .html file and ist .css file. I call the .css trough the instruction

<link rel= stylesheet href= mystyle.css>

But if I use

<link rel= "stylesheet" href= "mystyle.css">

then nothing changes in my page. Is there some difference between using the quotes or not?

mar tin
  • 9,266
  • 23
  • 72
  • 97

2 Answers2

1

I believe the spec defines it to have quotes, but some browsers go beyond and will know what you meant.

EDIT: I was wrong! From the spec

Attributes are placed inside the start tag, and consist of a name and a value, separated by an "=" character. The attribute value can remain unquoted if it doesn't contain space characters or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string.

http://www.w3.org/html/wg/drafts/html/master/introduction.html#restrictions-on-content-models-and-on-attribute-values

damian
  • 1,419
  • 1
  • 22
  • 41
0

In HTML5 you don't need to use quotes for any attributes. But, sometimes you have to because of knowing where a string ends. In HTML4.1 and XHTML you have to use quotes.

It's a good practice to use quotes anyway, even if you don't need them.

pzin
  • 4,200
  • 2
  • 28
  • 49