{"id":28,"date":"2008-02-12T09:52:27","date_gmt":"2008-02-12T15:52:27","guid":{"rendered":"http:\/\/cssnewbie.com\/basic-techniques\/comments-organize-css-design\/"},"modified":"2008-02-12T09:52:27","modified_gmt":"2008-02-12T15:52:27","slug":"comments-organize-css-design","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/comments-organize-css-design\/","title":{"rendered":"Use Comments to Organize Your CSS Design"},"content":{"rendered":"<p><img src='https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/02\/organize-comments.jpg' alt='The Paper Edit, by Detritus.' title='Photo by Detritus. Used under a Creative Commons License.' \/><\/p>\n<p>It\u2019s inevitable: the longer you work with CSS, the longer your CSS files will grow. And the longer your files get, the tougher it will be to find what you\u2019re looking for when you go back to edit your website\u2019s styles later on down the road. This is where CSS comments can really come in handy.<\/p>\n<p>The syntax is amazingly simple: You start a CSS comment with \/* and end them with *\/ \u2013 like so:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">\/* This is a CSS Comment. *\/\nbody {\n\tfont-size: 80%;\n}<\/pre>\n<p>A single CSS comment can also span multiple lines, like this:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">\/* This CSS was written by Rob.\n   He thinks of it as his own child, so\n   you'd be best off asking permission\n   to use it. ;)\n*\/\nbody {\n\tfont-size: 80%;\n}<\/pre>\n<p>So what are CSS comments good for? Well, in addition to identifying the creator of a CSS file (as shown above), you can also use your comments to keep your CSS more organized. For example, I use comments to organize my CSS into sections, like this:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">\/* Top navigational elements. *\/\nul#topnav {\n\tproperty: value; \n}\n\n\/* Main content area. *\/\n#content {\n\tproperty: value;\n}<\/pre>\n<p>This makes it much easier to come back though and add or remove values from a stylesheet later on.<\/p>\n<p>I also use comments to identify any \u201chacking\u201d I\u2019ve been forced to do.<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">.column {\n\theight: 1%; \/* Makes IE behave itself. *\/\n}<\/pre>\n<p>That way, if the hack ever becomes unnecessary or causes a different problem down the line, it\u2019s that much easier to find it.<\/p>\n<p>What else do you use CSS comments for?<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>It\u2019s inevitable: the longer you work with CSS, the longer your CSS files will grow. And the longer your files get, the tougher it will be to find what you\u2019re looking for when you go back to edit your website\u2019s styles later on down the road. This is where CSS comments can really come in handy. [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/comments-organize-css-design\/\" title=\"Click to read 'Use Comments to Organize Your CSS Design'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[168,192],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/28"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}