Forum Moderators: not2easy
Q. 1. Do I have to place spaces in between the property and value and place spaces in between all semicolons or is this done just for neatness?
Ex.
<p style="color:spacehere red; spacehere font-family:space here verdana; etc.">
I ask this because I'm new to CSS and I have seen other sites not space it out and it works fine.
I personally have placed it all together and it works fine. I just want to make sure I'm doing it correctly. Again, I am new to CSS. And I have looked everywhere and no site explains if you have to do it or not. This may seem like a dumb question, but I'm kind of a perfectionist and want to do right.
Q. 2. Do you have to place a semicolon at the end of the last value? I have seen other sites and some do and some don't. Is it neccessary to do so?
Ex.
<p style="color: red; font-family: verdana; font-size: 75%;here">
Please explain and show the proper way as I'm thinking that if I don't do it right, maybe some browsers won't display it properly. I have read that in html tables, if you don't include ending tags, it won't display. I have also read that, at some time, you will need to include the ending meta tags in the meta or it won't work properly. And I was a little worried that it might affect the CSS by not displaying in some browsers. Again I am new to CSS and I apologize if these questions might seem dumb and ameuterish but I want to code it correctly and I want it to display.
Please, can anyone help me?
Thank you to all.
Q. 1. Do I have to place spaces in between the property and value and place spaces in between all semicolons or is this done just for neatness?
No you don't need the spaces, it is just done for neatness/ease of reading. And when you get to external stylesheets often times people place the rules on a seperate line too.
e.g.
p {
color: red;
font-family: verdana;
etc...
}
but again it is not required, it's the equivalent of indenting your HTML.
Q. 2. Do you have to place a semicolon at the end of the last value? I have seen other sites and some do and some don't. Is it neccessary to do so?
No again you don't need to but it is considered good practice to do so as it will help avoid errors, and besides, imo anyway, it's just habit to always use it regardless of first or last rule ;)
Suzy
You don't need spaces between property and value. For the most part, unneeded spaces are simply ignored, just like they are in html. But you should never use a space between a numeric measurement and its unit, such as 1px. "1 px" won't work.