CSS Comments |
This is a discussion on CSS Comments within the Web Design Resources forums, part of the Development Resources category; Commenting is a vital part of coding, and its not usually until you come back to work on some code ... |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
![]() Join Date: Jan 2009
Posts: 730
Blog Entries: 16 Thanks: 17
Thanked 34 Times in 34 Posts
![]() Expertise: Design & Graphics Experience: Quite Good |
Commenting is a vital part of coding, and its not usually until you come back to work on some code you did a couple of years before you realise how helpful it would be to know what is doing what. CSS Syntax: Comments begin with /* Comments end with */ The hardest part I have is remembering if its */ or /*, the easiest way to remember it is "slar"(slash-star), and the end comment is the reverse. Examples of CSS Comments: Code: /*comment*/
body {/*comment*/ background: #fff;}
body {background: #fff;} /*comment*/
body {
/*
comment
*/
background: #fff;
}
Code: /* "£" '%' *%* () {} [] # @ ; : ? / \ | ! & - + = _ */
But you can never use too many comments, thats the best thing to remember. They will always be helpful, at least they are as long as they make sense. Your CSS code should be relative to the content, so if you have a right hand col it should be called something like: Code: .rightcol {width: 100px;}
Code: /* Right Column Div */
.rtdiv {width: 100px;}
Its all down to personal preference, I organise my code as below as I find it helpful: Code:
/* My CSS */
/* Import CSS Files */
@import url("global.css");
@import url("nav.css");
/* Body Style */
body {background-color: #333;}
/* Header Tags */
h1 {}
h2 {}
h3 {}
/* Content divs */
div.main {float: left; width: 600px;}
div.right {float: left; width: 200px;}
/* Footer */
.btmdiv {}
Tom
__________________ Fusion Web Hosting - Friendly and easy to use www.fusionservers.co.uk Last edited by Tom; 9th February 2009 at 08:14 AM.. |
| | |
| | #2 |
![]() Join Date: Jan 2009
Posts: 730
Blog Entries: 16 Thanks: 17
Thanked 34 Times in 34 Posts
![]() Expertise: Design & Graphics Experience: Quite Good |
Here is a new way I came up for displaying and organising CSS.. to make it a little easier to follow. You just need to design the layout of your site and the mark those sections and put the corresponding CSS underneath. That way you can easily tell which section relates to which part of your website, easy Code: /*
Tom over at webprocafe.com
Visual CSS Comments
2009
Enjoy!
*/
/*
Navigation
------------------------------
|xxxxxxxxxxxxxxxxxxxxxxx| |
------------------------------
| | |
| | |
| |=======|
| | |
| | |
| | |
------------------------------
| |
------------------------------
*/
.nav {}
.nav a:link {}
.nav a:hover {}
/*
Login
------------------------------
| |xxx|
------------------------------
| | |
| | |
| |=======|
| | |
| | |
| | |
------------------------------
| |
------------------------------
*/
.login {}
.login p {}
/*
Content
------------------------------
| | |
------------------------------
|xxxxxxxxxxxxxxxxxxxx| |
|xxxxxxxxxxxxxxxxxxxx| |
|xxxxxxxxxxxxxxxxxxxx|=======|
|xxxxxxxxxxxxxxxxxxxx| |
|xxxxxxxxxxxxxxxxxxxx| |
|xxxxxxxxxxxxxxxxxxxx| |
------------------------------
| |
------------------------------
*/
.content-wrap {}
.content p {}
.content a:link {}
/*
Adverts
------------------------------
| | |
------------------------------
| |xxxxxxx|
| |xxxxxxx|
| |=======|
| | |
| | |
| | |
------------------------------
| |
------------------------------
*/
.ad-50off {}
.ad-99off {}
.ad p {}
/*
ShoutBox
------------------------------
| | |
------------------------------
| | |
| | |
| |=======|
| |xxxxxxx|
| |xxxxxxx|
| |xxxxxxx|
------------------------------
| |
------------------------------
*/
.shout {}
.shout p {}
/*
Footer
------------------------------
| |
------------------------------
| | |
| | |
| |=======|
| | |
| | |
| | |
------------------------------
|xxxxxxxxxxxxxxxxxxxxxxxxxxxx|
------------------------------
*/
.footer {}
.footer p {}
__________________ Fusion Web Hosting - Friendly and easy to use www.fusionservers.co.uk Last edited by Tom; 10th February 2009 at 03:44 PM.. |
| | |
![]() |
| Tags |
| comments, css |
| Thread Tools | |
| Display Modes | |