I like to keep my code organized, usually in several files. It is good for CSS. For instance:
I have three files:
- First -
layout.html
, this is the main template. - Second -
grid.css
is style sheet where I decribe position of all elements. - Third -
style.css
is where I describe appearence of elements.
Listings:
<!DOCTYPE html>
<!--layout.html-->
<html>
<head>
<title>The best title ever</title>
<link rel="stylesheet" href="grid.css" type="text/css"/>
</head>
<body>
<!--The top part of site -->
<div id="header">
<h1>Header</h1>
</div>
<!--The main part of site, where al information is-->
<div id="main">
<!--Container with floating tabs. -->
<ul id="tabs">
<!--Floating tabs-->
<li id="tab1">Tab 1</li>
<li id="tab2">Tab 2</li>
<li id="tab3">Tab 3</li>
</ul>
<!--Container where we see content of ACTIVE tab-->
<div id="content">
Content
</div>
</div>
<!--The bottom part of site -->
<div id="footer">
Footer.
</div>
</body>
</html>
grid.css
/*
Rules for three base blocks.
*/
#header,#main,#footer{
width:990px;
margin: 0 auto;
padding:0;
}
/*
Rules for tabs.
*/
#tabs{
diplay:block;
overflow:auto;
padding:0;
margin:0;
}
#tabs li{
display:block;
float:left;
width:330px;
height:50px;
border: 1px solid silver;/*Uncomment it for debugging */
box-sizing:border-box;
-moz-box-sizing:border-box;
padding-top:10px;
text-align:center;
}
/*
Rules for content block.
*/
#content{
width:990px;
height:700px;
box-sizing:border-box;
-moz-box-sizing:border-box;
border:1px solid silver;/*Uncomment it for debugging */
}
style.css
body{
background-color:silver;
/*And all things like that, colors,fonts,etc..*/
}
What do you think of this code organization?
How do you organize your style sheets?