| So why would you want to learn all this stuff about Cascading Style Sheets? What do you gain from it? Plenty. Firstly you separate out the formatting from the text, as all the formatting goes in the header. This means that the search engines have cleaner code to index, your text is more likely to be ranked higher than non CSS text. Secondly it saves space and code. I halved the size of my front page using the simple CSS there. It also dramatically reduced the download times. Thirdly CSS give you the freedom to play with your setup quickly and efficiently. Fourthly CSS let you do things simply that take ages to work out in HTML, if it is possible to do it at all. Revolutionize your webpage design with this simple easy to use system. Take all, some, or none, of this to use as you like. The final page is here and the code is easily grabbed.
| |
| It is possible to create an incredibly fast loading and easily modified site using style sheets exclusively and not using tables at all. This frees the developer to use a simple program like notepad to maintain and update the site.
Here is how we will do it……
This is the final page, note what appears to be a complex series of tables holding the data and creating the buttons. |
|
Writing the page | |
| To create this we will first write the body…..
Cut and paste the code if you like.
Here is the raw page
See page here |
<BODY> SUCU Stuff U can Use For Internet resources and fun <A href="http://index.html">Home </A> <A href="http://aboutus.html">About Us </A> <A href="http://approach.html">Approach </A> <A href="http://services.html">Services </A> <A href="http://expertise.html">Expertise</A> <A href="http://people.html">People </A> <A href="http://contactus.html">Contacts </A> SUCU Partners </HTML> |
Creating a frame | |
| The first thing we will do is create the frame that will surround the page
First in the Head section set the style code …. |
<style type="text/css"> <!--
--></style>
|
| Inside this lets set the body of the text and the page first.
Making the font Verdana, the text color blue and the background color light blue |
<style type="text/css"> <!-—
body { color: #0033dd; background: #aabdff;} --></style> |
| Once you get that working, lets look at the code for the box itself.
Note that all we are making here is a box, (display: block), setting an outer margin, and padding on the inside.
We are making it 95% of the screen wide and giving it a yellow background color with a blue colored border
Put that in the style section, after the Body style…. |
.mainbox { padding: 20px;/*Padding == the space between the line border and the content*/ margin: 10pt;/*Margin == the space between the line border and the outside*/ display: block; /*Display = specifies how the element will be seen*/ width: 95%; background: #ffde6f; border: 3pt solid #0033dd;} (Note: the blue comments should run all the way across the page, don't break them )
Here it is working as it looks in the body section.
|
| Now we have to go to the body text and add the code to make it be seen…. After the body tag put the following… |
<BODY> <DIV class=mainbox>
at the very end of the page put
</DIV> </BODY> |
| Here is the Style code so far…
This alone is a great way to make your page stand out easily and quickly without having to create a table.
See page here
| <style type="text/css"> <!-- body { .mainbox { |
Title section of the page | |
| Lets format the title section….
Include the styles ….
The logo makes a big text (300%) that floats left, that is will be on the left and other text can be on the right. Its bold, italic and Times.
See page here
| /* 3 Headings at the page top */ .logo {float: left; /*Float = sets the direction of the element to end up - other things go beside it not below it*/ font-size: 300%; font-style: italic bold; font-family: "Times New Roman"; } .OurName { border-bottom: thin solid #002190; color: #002ab6; font-size: 180%; margin: 0pt 0pt 0pt 50%; /*margin = setting the length of the line in this cas the left margin starts at 50% of the screen*/ text-align: right;} .OurGame { color: #0033dd; font-size: 90%; font-style: italic; text-align: right;}
|
| Include in the body the classes…
These are quite straightforward, setting the formatting options for the text.
The margin in .ourname is setting the length of the underline. |
<BODY> <DIV class=mainbox> <p class=logo>SUCU <P class=OurName>Stuff U can Use <P class=OurGame>For Internet resources and fun
SUCU Stuff U can Use For Internet resources and fun |
Creating the buttons | |
| In this part we are going to create the buttons on the page. The first thing to do is make the blue background box that is behind the buttons.
Margins and padding have 4 sides … top, right, bottom and left. If there is only one number it applies to all sides.
Include the comments between the /* and */ so that you can keep a record of what you have made.
On both sides of the hyperlinks include the DIV code…Note that the hyperlinks are blue as well, so they are there but we can’t see them ….
See page here |
.headmenu {
/*All this does is set the blue box on the screen */ background: #0033dd; margin: 5pt 0pt 5pt 0pt; /*margin = setting the yellow space around the blue box top; right; bottom; left;*/ padding: 3pt 0pt 5pt 0pt; /*padding = setting the blue space inside the blue box top; right; bottom; left;*/ width: 100%; }
<DIV class=headmenu>
|
| This is the code for the links. As we only want some links to be boxes we have to define them, so they are called hls .. you could call them anything you like.
This makes the links a BLOCK – so little boxes, that FLOAT over the blue headmenu box earlier. The boxes have borders and are padded and colored, and the links are colored white.
See page here
| /* links at the page top */ a.hls:link, a.hls:visited, a.hls:active { background: #002190; border: solid 2px #aabdff; /*makes a solid border around the link 2px wide*/
/*makes a block around the link */
/*margin = setting the blue space around the boxs*/
In the body add the Class=hls code to the links.
<DIV class=headmenu> |
Creating the Sub Headings | |
| The subheading has a blue box around it that extends for the width of the page.
| .heading { background: #0033dd; color: white; font-variant: normal; font-weight: bold; font-size: 100%; margin: 5pt 0pt 5pt 0pt; padding: 3pt 0pt 3pt 5pt} |
| Add the following code to the body around the SUCU Partners text.
See page here
| H1 class=heading>SUCU Partners</H1>
SUCU Partners |
Formatting the Picture | |
| The picture is FLOATING on the right allowing the text to fill the left side. There is a margin on the bottom to stop text getting too close to the pic and a border is placed around the pic. |
.rstuff { float: right; margin: 0pt 0pt 0pt 5pt; width: 360px} img {border: thin solid #002ab6;} |
| Change the code in the body to this …
See page here
| <IMG class=rstuff src="emea3.jpg" width=360> (note with this code if you place another pic on the page it too will have a blue border) |
Formatting the End | |
| The text at the bottom is CLEAR of the floating picture, so will always below the float never beside it. | .bottom { clear: both; /*clear = makes the text stay clear of any floating elements around it .. in this case the pic*/ font-size: 80%; padding: 5px;} |
| In the body add the following code. Note that useful FLOAT returns to push the text either left or right. | <DIV class=bottom> <P style="FLOAT: left">©Copyright 2002 SUCU Partners <P style="FLOAT: right"><A href="http://contactus.html">Contact Us</A> </DIV>
©Copyright 2002 SUCU Partners |
| And here is the final page. If you go View / Source you can get all the code for it.
| |