Forum Moderators: not2easy

Message Too Old, No Replies

Inlining CSS into body of a page.

Can anyone help me please.

         

frenzy77

9:17 am on May 4, 2004 (gmt 0)

10+ Year Member


Hello everyone. I'm new here and I have a couple of questions about inlining styles into the body of my page.

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.

SuzyUK

10:56 am on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi frenzy77 - Welcome to WebmasterWorld

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

jetboy_70

11:03 am on May 4, 2004 (gmt 0)

10+ Year Member



Beat me to it!

Even in the W3C's CSS specs examples they seem to alternate between including a trailing semicolon and leaving it out, despite it not being included in the syntax guidelines.

sonjay

1:20 pm on May 4, 2004 (gmt 0)

10+ Year Member



I always put each css declaration on a separate line and always use the trailing semi-colon; that makes it easy to copy or cut and paste any declaration from one style to another style.

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.

frenzy77

5:31 am on May 5, 2004 (gmt 0)

10+ Year Member



From frenzy77

Thank you to everyone for your help!
It's great to know that people here
really want to help.