[Tutorial] Learn xHTML/HTML and CSS

Well done with your tutorials thus far. I really like the way you are explaining them. It took me awhile to get some of these concepts down because I would go to some other tutorials and just play around until I figured out how the tags / css actually worked back when I started learning, but you are speeding that process up for others here. Keep it up!
 
Well done with your tutorials thus far. I really like the way you are explaining them. It took me awhile to get some of these concepts down because I would go to some other tutorials and just play around until I figured out how the tags / css actually worked back when I started learning, but you are speeding that process up for others here. Keep it up!

Well thanks for you reply because that is exactly why I choose to lay out the post this way.

I am available to answer any question anyone might have about anything that has been done so far. Reply here if you do have a question so that everyone may learn. They may also have the same question to ask.
 
For all the people who want to learn basic CSS, go here:

www.codecademy.com

HIGHLY recommended. Super noob friendly and I was able to put it into practice within a week :p
 
Thank you for your input, but this tutorial has been laid out for long-term memory for the readers. Reason for this is to have the readers be confident in their abilities with html and css. This will allow them to put the code into practice straight away.

If you don't believe me you can wiki distributed practice. I googled this stuff before posting this tutorial to see how best people learn.

If you want me to speed it up that is always an option. But it will not benefit most people here.

For all the people who want to learn basic CSS, go here:

www.codecademy.com

HIGHLY recommended. Super noob friendly and I was able to put it into practice within a week :p
 
I've got to agree with Brendan. I've popped in and out of tutorials got bored butchered code, did what I had to and learned nothing.

With these tutorials things are falling into place. And we're getting to the punchline without any drivel.

The posts are broken up into logical steps which makes it easier to remember.
 
Thanks man. Reason for the layout is because I have been there done what you have said and got nowhere fast. But after a while I began to understand the code, not remember how to write it.

I've got to agree with Brendan. I've popped in and out of tutorials got bored butchered code, did what I had to and learned nothing.

With these tutorials things are falling into place. And we're getting to the punchline without any drivel.

The posts are broken up into logical steps which makes it easier to remember.
 
Styling Links,Tables and Lists

Welcome back to my tutorial. Today we will be covering how to style links,tables and lists. This is the last of Internal we will be using. The rest will be External and since there isn?t much of a difference between them we will shortly be finished learning xHTML/HTML and CSS.

Steps:


  1. Open skeleton.html in notepad
  2. Save file as finish_internal.html
  3. Type as follows:

    Code:
    <html>[INDENT]<head>[/INDENT]
    [INDENT=2]<style type="text/css">
    
    [/INDENT]
    [INDENT=3]a:link {
    [/INDENT]
    [INDENT=3]color:#FF0000;
    [/INDENT]
    [INDENT=3]text-decoration:none;
    [/INDENT]
    [INDENT=3]background-color:#B2FF99;
    [/INDENT]
    [INDENT=3]}
    [/INDENT]
    [INDENT=3]/* unvisited link */
    
    [/INDENT]
    [INDENT=3]a:visited {
    [/INDENT]
    [INDENT=3]color:#00FF00;
    [/INDENT]
    [INDENT=3]text-decoration:none;[/INDENT]
    [INDENT=3]background-color:#FFFF85;[/INDENT]
    [INDENT=3]} [/INDENT]
    [INDENT=3]/* visited link */
    
    [/INDENT]
    [INDENT=3]a:hover {
    [/INDENT]
    [INDENT=3]color:#FF00FF;[/INDENT]
    [INDENT=3]text-decoration:underline;[/INDENT]
    [INDENT=3]background-color:#FF704D;[/INDENT]
    [INDENT=3]}[/INDENT]
    [INDENT=3]/* mouse over link */
    
    [/INDENT]
    [INDENT=3]a:active {[/INDENT]
    [INDENT=3]color:#0000FF;[/INDENT]
    [INDENT=3]text-decoration:underline;[/INDENT]
    [INDENT=3]background-color:#FF704D;[/INDENT]
    [INDENT=3]} 
    [/INDENT]
    [INDENT=3]/* selected link */ 
    
    [/INDENT]
    [INDENT=3]table { [/INDENT]
    [INDENT=3]table-layout: auto;[/INDENT]
    [INDENT=3]border: 1px solid;[/INDENT]
    [INDENT=3]border-spacing: 10px 5px;[/INDENT]
    [INDENT=3]border-collapse: collapse;  [/INDENT]
    [INDENT=3]}
    
    [/INDENT]
    [INDENT=3]td{[/INDENT]
    [INDENT=3]border: 1px solid;[/INDENT]
    [INDENT=3]empty-cells: hide;[/INDENT]
    [INDENT=3]}
    
    [/INDENT]
    [INDENT=3]caption{[/INDENT]
    [INDENT=3]caption-side: right;[/INDENT]
    [INDENT=3]}
    
    [/INDENT]
    [INDENT=3]ul { [/INDENT]
    [INDENT=3]list-style-type: none; [/INDENT]
    [INDENT=3]list-style-position:outside;[/INDENT]
    [INDENT=3] }
    
    [/INDENT]
    [INDENT=3]ol { [/INDENT]
    [INDENT=3]list-style-type: circle; [/INDENT]
    [INDENT=3]list-style-position:outside; [/INDENT]
    [INDENT=3]}
    
    [/INDENT]
    [INDENT=2]</style>
    
    [/INDENT]
    [INDENT=2]<title>Full Internal CSS</title>[/INDENT]
    [INDENT]</head>[/INDENT]
    [INDENT]<body>[/INDENT]
    [INDENT=2]<br />
    <a  href = "http://www.google.com/"> Go to google.</a>
    <br />
    <br />
    <a href = "http://www.google.com/"> Go to google.</a>
    <br />
    <br />
    <a href = "http://www.google.com/"> Go to google.</a>
    <br />
    <br />
    <a href = "http://www.google.com/"> Go to google.</a>
    <br />
    <br />
    
    <table>[/INDENT]
    [INDENT=3]<tr>[/INDENT]
    [INDENT=4]<td>This is cell 1</td>
    <td>This is cell 2</td>
    [/INDENT]
    [INDENT=3]</tr>
    <tr>[/INDENT]
    [INDENT=4]<td>This is row 2 cell 1</td>
    <td></td>
    [/INDENT]
    [INDENT=3]</tr>
    <caption>This is the caption do you like it</caption>
    [/INDENT]
    [INDENT=2]</table>
    
    <ul>[/INDENT]
    [INDENT=3]<li>First in un-ordered list</li>
    <li>Second in un-ordered list</li>
    <li>Third in un-ordered list</li>
    [/INDENT]
    [INDENT=2]</ul>
    
    <ol>[/INDENT]
    [INDENT=3]<li>First in ordered list</li>
    <li>Second in ordered list</li>
    <li>Third in ordered list</li>
    [/INDENT]
    [INDENT=2]</ol>
    [/INDENT]
    [INDENT]</body>
    [/INDENT]
    </html>
  4. Save file
  5. Open finish_internal.html in a browser. Click some links, hover over links, try out everything you can with links.


Breakdown:

All I have done here is introduce you to how to write the styles for tables,lists and links. Look at each and interpret what they can do. It should be pretty obvious by now to you. You may notice that there is comments here, they do not be displayed but are visible if you view page source.

Please remember to change this code as you please. It will help you learn.
"In life, there are no mistakes, only lessons."
? Vic Johnson, Day by Day with James Allen
 
External CSS

Welcome back to my HTML/CSS tutorial, Today you will be learning how to create external stylesheets. This is where CSS really becomes alive. This is the most efficient and useful way possible.
To get into that thou, I will need to explain the theory behind CSS, this is where you will be getting your ah-ha moment.

We will be discussing the box model in CSS. Everything will be so clear to you after this is explained.

Everything on a web-page is a box, no other way to look at it. Everything is a box that fits inside another box.This means that Margins, Padding, Dimensions, Border, Background, Font, Positioning; anything on a web page can be altered using CSS Box Model.

Steps:


  1. Open skeleton.html in notepad
  2. Save file as box_model.html
  3. Type as follow:

    Code:
    <html>[INDENT]<head>[/INDENT]
    [INDENT=2]<title>Box Model</title>
    <link rel="stylesheet" type="text/css" href="external.css">
    [/INDENT]
    [INDENT]</head>[/INDENT]
    [INDENT]<body>[/INDENT]
    [INDENT=2]<div id="container">[/INDENT]
    [INDENT=3]<p>Edge  of the White is the padding, after that is the red which is the border,  then is the margin which is grey. And everything in the middle is the  Content. This is what the box model is. I created this so that it would  be easier. Seeing the box is the only way to learn the box  model.</p>
    
    <ul>[/INDENT]
    [INDENT=4]<li>Box Model Shows</li>
    <li>Margin</li>
    <li>Padding</li>
    <li>Border</li>
    [/INDENT]
    [INDENT=3]</ul>
    
    <ol>[/INDENT]
    [INDENT=4]<li>Box Model Shows</li>
    <li>Margin</li>
    <li>Padding</li>
    <li>Border</li>
    [/INDENT]
    [INDENT=3]</ol>
    
    <table>[/INDENT]
    [INDENT=4]<td>Box Model Shows</td>
    <td>Margin</td>
    <td>Padding</td>
    <td>Border</td>
    [/INDENT]
    [INDENT=3]</table>
    [/INDENT]
    [INDENT=2]
    </div>
    [/INDENT]
    [INDENT]</body>
    [/INDENT]
    </html>
  4. Save file

    External CSS File
  5. Open notepad
  6. Save file as external.css
  7. Type as follows:

    Code:
    body {
    background: black;
    }
    
    #container {
    background: gray;
    width: 600px;
    height: 400px;
    margin: 0px auto;
    border: 1px solid black;
    }
    
    p { 
    background: white;
    border: 20px solid red;
    margin-top: 20px;
    margin-right: 20px;
    margin-bottom: 20px;
    margin-left: 20px;
    padding-top: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    padding-left: 20px; 
    }
  8. Save file
  9. Open box-model.html in browser

Now replace the styling from above with this. Will really help with seeing how the box model works.

Code:
*{
border:1px solid red !important;
}

Now that you know exactly how CSS works and where it is used, you can now learn the standard way of using CSS. By making it external, it has to be only written once and used on many pages, this creates the look and feel of the whole website. Internal is the backup to external, it is to only be used on pages that need individual styling. In-line is only used when a single tag on the entire website needs individual styling.

I have explained the syntax of a CSS and what can be done, but that doesn?t really demonstrate why and how to use CSS. This post is the most important post in this thread.


How to use External CSS?

Simple, it is the same as internal but taken out and placed into a separate file from the HTML. This file is a ?.css? file. Then all you have to do is call the CSS file into the pages that will be using it. This is simply done by replacing the Internal CSS style tag to;
Code:
<link rel="stylesheet" type="text/css" href="name.css">
and taken the internal styles and the ending style tag away.


Play around with the code, always testing to see if you can achieve the effects you desire.
Soon I will have a little treat for everyone here on BHW! Hope you all will enjoy it.
"In life, there are no mistakes, only lessons."
? Vic Johnson, Day by Day with James Allen
 
A nice initiative OP. Kudos.
I would like to point out a minor thing. You have used shorthand properties but no where explained. Ex: border:20px solid red;
i.e. Short Hand Properties. They save your time as you do not have to type the lengthy properties.

Anyone who has his/her student cap on for CSS here is one example:

HTML:
background-image:url('link of image');
background-repeat:no-repeat;
background-position:right top;
background-attachment:fixed;

So whats common in above CSS properties ? Yup its background.

So the above codes can be trimmed down to :

HTML:
background:url('link of image') no-repeat right top fixed;

Parent property with values separated with a space. :D
 
Last edited:
A nice initiative OP. Kudos.
I would like to point out a minor thing. You have used shorthand properties but no where explained. Ex: border:20px solid red;
i.e. Short Hand Properties. They save your time as you do not have to type the lengthy properties.

Anyone who has his/her student cap on for CSS here is one example:

HTML:
background-image:url('link of image');
background-repeat:no-repeat;
background-position:right top;
background-attachment:fixed;

So whats common in above CSS properties ? Yup its background.

So the above codes can be trimmed down to :

HTML:
background:url('link of image') no-repeat right top fixed;

Parent property with values separated with a space. :D

yeah good point i made no mention of this. But you are correct that is the best way to do it. Nice share and thanks saved me time explaining it.
 
I hope you dont mind if i post regarding CSS aswell. Though i do not really want to hijack your thread. ;) Permission required.
 
Back
Top