Finishing from where I left off!
Before we move onto the divs I must insist on showing you how to place a comment inside your stlyesheet!
Code:
... code here
<style>
/* This is a comment in a stylesheet! */
</style>
... code here
Ok so now we come to divs!
Divs are now more commonly used in web design instead of tables. Apparrently as a proffessional web designer you are supposed to use Divs to create your website, and only use tables for tabular data!
So here is what you do to create a Div!
Code:
<html>
<head>
<title>Div Example</title> <!-- Gives the page the title "Div Example -->
<!-- Again i reccomend external stylesheet but for this purpose the inline style is being used -->
<style>
.div1
{
background-color: #000000;
color: #FFFFFF;
}
/*This Style is going to give Div1 a background colour of black and a font colour of white */
</style>
</head>
<body>
<div class="div1">
Content in here
</div>
</body>
</html>
So that is a div with a background color of black and a font colour of white. Now there are many more properties that you could add to this and I am going to show you some right now!
Code:
... code here
<style>
.div1
{
background-color: #000000;
color: #FFFFFF;
width: 200px;
margin-left: 50px;
margin-top: 300px;
}
</style>
</head>
<body>
<div class="div1">
Content here
</div>
.... code here
That is the same div as I coded earlier, however I added some extra properties to it! I made the width of the div 200 px (Ideal for navigation areas!) and I made it start 50px from the left and 300px from the top!
Now for those of you that don't know this already px stands for pixels. I always code my layouts using pixels, and so do many others, however there are others out there, which you can find on a different website! (Just Place w3schools.com into google and you will find it!)
So below are explained some of the other attributes that you can add to a div!
- margin - Now the value you set on this will apply to all sides top, bottom, left and right! You can change it so it only applies to the one side e.g. margin-left applies it to the left hand side only
- width - This sets the width of the div itself so a decent size for a navigational area I believe is 200px!
- height - This sets the height of it, but this doesn't always need to be added as the div will expand to the height of its content!
- position - This will determine the position of the Div! I believe you can get, absolute, static, and a few others
Now that is the end of the tutorial! I have covered the basics of HTML and the basics of CSS and I have shown you how to combine the two together!
Again I reccomment you use external stylesheets on all your websites, which makes it a hell of alot easier when your coding and making small tweaks to the layout etc!
This tutorial will soon available on my website as a whole!
Regards,
Zenax
A Link to colour code chart : Click Here