Happy TutorialsYou probably know, or have heard about CSS, but it's good to go through the basics of CSS Layout just ot make sure.
In the beginning we had HTML page - which uses tags like <p></p> which meant paragraph. Anything within the <p> tags looked like a paragraph. <h1></h1> meant header, some all text within this looked bigger and bolder. <h2> was a slightly smaller header. It was limited to say the least.
Poeple want to add 'design' to their pages. So more and more tags came along. <font> allowed you add fonts, <b> means bold. But it soon became very confusing, and still quite limited.
CSS. Cascading Style Sheets. CSS sheets are very useful.
We still use HTML tags as normal, but then we create sets of styles, and tell the various tags/elements on our page to use these different styles.
CSS layout makes extensive use of the <div> tag. A div tag is basically an empty box, or container. It doesn't really do anything! But, we can create style, for example 'PAGE', give this style a width, background colour, tell it what font to use, and the colour of the font. Then, we create a DIV, and tell it to use the style 'PAGE'. The div then takes these sytles, and becomes a certain width, and background colour, and all the text you enter into this box will use the font and colour of font you defined in the style sheet.
Now, we wan't the HTML page to use this style sheet. In the HTML file
|
Lets start on the HTML page by splitting the view, to see the visual look, and the source code
You should see the code at the top, with various bits of basic HTML code in, and a plain page in the design window.
If you click in the design window, and then look into the code window, your cursor will now be between the openning and closing <body> tags
Create a DIV tagWithin the Body tags, create a div tag like this:
HTML |
Human Person Language |
<body>
</body> |
within the body tag - eg, it's on the visible page
create a DIV tag |
If you click back into the design view, you should now see a rectangle. This is the div.
Adding an ID
add an ID to this DIV like this:
HTML |
Human Person Language |
<div id = "myHeader"></div> |
this div has an id name of 'myPage' |
Now add a few more DIVs, like this:
HTML |
Human Person Language |
<div id="myHeader"></div> |
this is the header this is the main page this is the footer |
Lets go over the CSS file. At the moment it will be pretty much empty, if there are some lines at the top, don't worry just carry on below these lines
The Body
CSS |
Human Person Language |
body {background-color:#666666; } |
this find the element which is a <body> tag, and gives it these styles, widith, and a grey background colour |
The DIVS
We've given each DIV a different ID, and we want to each one to have a different set of styles. So, we need to create a style that will be added to a tag with a specif ID
CSS |
Human Person Language |
#myHeader { width:800px; background-color:#003333; height:50px; } |
this adds styles to the tag with the ID of 'myHeader' this adds styles to the tag with the ID of 'myPage' this adds styles to the tag with the ID of 'myFooter' |
Notice we put a # before the ID name of each DIV, this tell the style sheet that this style relates to the ID, whereas the body style simply relates to a the <body> tag.
If you go back to the HTML page, you should now see a layout with 3 rows, each a different colour.
Lets add a menu in here now
In the CODE view, add another div, beneath the 'myHeader' div, and give it the id 'myMenu', also create a CSS style for this menu area
HTML |
CSS |
<div id="myMenu"></div> |
#myMenu { width:800px; background-color:#66CCFF; height:20px; } |
Back in the design view of the HTML page, you should see a blue menu bar.
Creating the links
In the desing view, or the source view, type a few words (eg Home About Contact) within the Menu div
Select the words, and enter a # into the link box (in the properties window). This makes them into links, but the # means they are blank, and don't go anywhere. We have nowhere for them to go anyway just now!
If you look at the code view again, you'll see the links are now in there on one line. You may find its looks nicer by putting them on multiple lines
HTML |
Human Person Language |
<div id="myMenu">
|
this is basically a <a> tag. I means Anchor (but they are links). The A tages have a property HREF="" - this defines where the user goes when they click. # means go nowhere! |
Stlying the links
Now, we can add some more code the CSS file to make the links in the menu area look better
CSS |
#myMenu a { color:#006666; font-weight:bold; } |
This line combines the two CSS methods we used before. The #myMenu target the tag with the ID 'myMenu', and the 'a' looks for any 'a' tags (eg, the links) that are within the #myMenu area. It won't affect any links anywhere else.
If you go back to the HTML page, you should now see that the links are a kind of dark green colour, and bold. Not very pretty, but we'll improve it all later.
To make the ideal, most useful tutorials, I need your comments. Did you understand everything, did I make any mistakes, or not explain something? Did it simply not work! Let me know