hi guys, I'm a total beginner so for now this is going to be basic stuff...... In the syntax below, should myimage.jpg be in single quotes, in double quotes or in no quotes? Body {background-image:url(myimage.jpg);} In W3Schools tutorials I'm seeing single quotes in the text, but in their Example it's double quotes. An online search is throwing up samples with no quotes. Also..... Is there a definitive CSS Reference somewhere online that lists not just CSS properties but also their corresponding values? Thanks for any assistance, Eva
Hey, to answer your first question, you can use: CSS Code: body { background:url(myimage.jpg); } I don't think the quotes are necessary, because I don't use the quotes on any of our websites. The quotes are pretty much optional Online, W3Schools does give CSS properties and their values. You can go to http://www.w3schools.com/css/css_positioning.asp for an example, and just scroll down near the bottom of the page, and it lists the CSS properties, along with a description and their values. Not all CSS properties will have specific values though... Hope this helped - Jason
The only time you need quotes in a CSS property is if it has SPACES in it or it's a string literal. Font-family is a great example of the former: font-family: "Courier New",courier,serif; courier and serif dont' need quotes, there's no spaces in them... courier new has spaces in it, so you're supposed to use quotes. background-image:url(images/myTest.png); no spaces needed. background-image:url("images/my Test.png"); This is because CSS properties use spaces as delimiters... re: padding:4px 4px 8px 0; So it makes life easier on the parser. String literals are a bit rare, the only example I can think of is generated content. content:"any text on the content property must be in quotes"; Though if you're looking around the web, most people never bother doing what you are doing when they should -- asking "WHY" and "WHEN" -- but again most people just sleaze out their HTML and CSS any old way without taking the time to bother learning how either technology works. Site after site you'll see people throwing them in for no reason, or omitting them when they should be there because they pretty much just copypasta bad code or bad habits.
Thanks deathshadow, this is very useful to know. I have added it to a "Working Manual" I'm compiling as I go. Also agree with your stance on learning code. I'm hoping time invested in learning the details now will pay dividends later in time and money saved. But best of all it will give creativity a free run. Cheers! Eva.
@deathshadow, Thanks for this. I've been coding websites since 2 months and I didn't knew this (didn't bother to find out xD). I've posted it on my blog so that I can recall in future if anyone asks the same question. Thanks.