Fantasia's Crash Course in HTML/CSS
Welcome all! As per request, I decided to make a guide to easily explain the logic behind HTML/CSS. It is a basic skill that everyone should know and I hope by the end of this tutorial that you all will have the skills to build your own websites or even make your own Tumblr themes. It is important that you have a text editing tool to begin. The default on many computers is Notepad, I personally used Notepad++ which uses colors to head display easier, but as long as it is a raw text editing tool (NOT MS word), then it will work.HTML Guide
The first thing important to understand about html is the use of <, / and >. Think of these symbols like a command. All commands in HTML lie within < and > and it calls something to be done. For instance, later we will talk about an image tag which appears as <img src="URL">, as we see, the command lies between two < and >.
Tags
We are going to take a look at our first stylesheet. Text in purple is a tag. Text in orange is not part of the stylesheet and should be used as a guide. As you can see above each tag begins in <and> and ends in </and>
Basic Commands
Here are some common commands you might see and what they all mean. Commands are listed in green.
<LINK rel="stylesheet" href="/style.css"> : This might appear the in <head> </head> tags and calls your CSS stylesheet, which we will learn about later.
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" /> : This might appear in the <head> </head> tags and adds a "favicon" to your page. This is the little tiny image that appears in the left hand side of a tab display. For example, the myVMK forums favicon is the small blue castle.
<div id="DIV NAME"></div> : Found in the <body> </body> tags and calls a DIV which is a box, we will talk about this more in the CSS section.
<h1>TITLE</h1> : Found in the <body> </body> tags and makes a header. You can keep going through each header eg. h1, h2, h3 and the text will get smaller, but in default . We will learn how to edit a header in the CSS section.
<b>BOLD</b> : Found in the <body> </body> tags and bolds the enclosed text. We will learn how to edit bold text in the CSS section.
<i>ITALICIZE</i> : Found in the <body> </body> tags and italicizes the enclosed text. We will learn how to edit italicized text in the CSS section.
<u>UNDERLINE</u> : Found in the <body> </body> tags and underlines the enclosed text. We will learn how to edit italicized text in the CSS section.
<a href="LINK URL">LINK NAME</a> : Found in the <body> </body> tags and links the enclosed text. We will learn how to edit linked text in the CSS section.
<img src="IMAGE URL"> : Found in the <body> </body> tags and displays an image.
<br> and <p> : Found in the <body> </body> tags. <br> Knocks the text down one line and <p> skips one line.
<p class="CLASSNAME"></p> : Not to be confused with <p>, this will enclose your text with a style indicated by the class. This will not work the same way as a DIV and should not be used for positioning. We will learn how to edit classes in the CSS section.
Sample Stylesheets
So yes, you ALREADY have all the knowledge to build a simple stylesheet. Lets take a look at what a basic one might look like.
Congratulations! You now know all you need to build a webpage. Let's talk about CSS and find out how to make it pretty.
Tags
We are going to take a look at our first stylesheet. Text in purple is a tag. Text in orange is not part of the stylesheet and should be used as a guide. As you can see above each tag begins in <and> and ends in </and>
Code:
[COLOR="DarkOrchid"]<html>[/COLOR]
[COLOR="DarkOrchid"]<head>[/COLOR]
[COLOR="Orange"]Your head contains all info you don't want to appear on the page. Things that go here may be a link to your CSS stylesheet, meta tags (things that appear in search browers), and Javascript.[/COLOR]
[COLOR="DarkOrchid"]<title>[/COLOR]Name that appears on tab[COLOR="DarkOrchid"]</title>[/COLOR]
[COLOR="DarkOrchid"]</head>[/COLOR]
[COLOR="DarkOrchid"]<body>[/COLOR]
[COLOR="orange"]Your body contains all the info that does appear on your final page. It might have boxes you have on your page, images you display, and text you write.[/COLOR]
[COLOR="DarkOrchid"]</body>[/COLOR]
[COLOR="DarkOrchid"]</html>[/COLOR]
Here are some common commands you might see and what they all mean. Commands are listed in green.
<LINK rel="stylesheet" href="/style.css"> : This might appear the in <head> </head> tags and calls your CSS stylesheet, which we will learn about later.
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" /> : This might appear in the <head> </head> tags and adds a "favicon" to your page. This is the little tiny image that appears in the left hand side of a tab display. For example, the myVMK forums favicon is the small blue castle.
<div id="DIV NAME"></div> : Found in the <body> </body> tags and calls a DIV which is a box, we will talk about this more in the CSS section.
<h1>TITLE</h1> : Found in the <body> </body> tags and makes a header. You can keep going through each header eg. h1, h2, h3 and the text will get smaller, but in default . We will learn how to edit a header in the CSS section.
<b>BOLD</b> : Found in the <body> </body> tags and bolds the enclosed text. We will learn how to edit bold text in the CSS section.
<i>ITALICIZE</i> : Found in the <body> </body> tags and italicizes the enclosed text. We will learn how to edit italicized text in the CSS section.
<u>UNDERLINE</u> : Found in the <body> </body> tags and underlines the enclosed text. We will learn how to edit italicized text in the CSS section.
<a href="LINK URL">LINK NAME</a> : Found in the <body> </body> tags and links the enclosed text. We will learn how to edit linked text in the CSS section.
<img src="IMAGE URL"> : Found in the <body> </body> tags and displays an image.
<br> and <p> : Found in the <body> </body> tags. <br> Knocks the text down one line and <p> skips one line.
<p class="CLASSNAME"></p> : Not to be confused with <p>, this will enclose your text with a style indicated by the class. This will not work the same way as a DIV and should not be used for positioning. We will learn how to edit classes in the CSS section.
Sample Stylesheets
So yes, you ALREADY have all the knowledge to build a simple stylesheet. Lets take a look at what a basic one might look like.
Code:
[COLOR="DarkOrchid"]<html>[/COLOR]
[COLOR="DarkOrchid"]<head>[/COLOR]
[COLOR="DarkOrchid"]<title>[/COLOR]myVMK Beta[COLOR="DarkOrchid"]</title>[/COLOR]
[COLOR="YellowGreen"]<LINK rel="stylesheet" href="/style.css">[/COLOR]
[COLOR="YellowGreen"]<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />[/COLOR]
[COLOR="DarkOrchid"]</head>[/COLOR]
[COLOR="DarkOrchid"]<body>[/COLOR]
[COLOR="YellowGreen"]<div id="blog">[/COLOR]
[COLOR="YellowGreen"]<h1>Latest Newsletter</h1>[/COLOR]
[COLOR="YellowGreen"]<b>4/26/2014:</b>[/COLOR] Hello let's talk about what has gone <i>on in</i> myVMK today. We had <u>some releases!</u>
[COLOR="YellowGreen"]<br><b>4/20/2014:</b>[/COLOR] Hello let's talk about what has gone <i>on in</i> myVMK today. We had <u>some releases!</u>
[COLOR="YellowGreen"]<p><b>4/15/2014:</b>[/COLOR] Hello let's talk about what has gone <i>on in</i> myVMK today. We had <u>some releases!</u>
[COLOR="YellowGreen"]</div>[/COLOR]
[COLOR="DarkOrchid"]</body>[/COLOR]
[COLOR="DarkOrchid"]</html>[/COLOR]
CSS Guide
As you saw in the HTML tutorials, there were many instances where I said we will learn how to style this with CSS. CSS is not what builds a webpage, but rather styles it. So if a structural engineer builds the building (they would be the HTML), an architect designs the building (they would be CSS). There are no tags like those we saw in HTML, rather treat a CSS page as if it is already in a giant tag.
There are two ways to put your CSS on the HTML page. You can either put it in <style></style> tags within the <head></head> tags, or you can link it in the <head></head> tags with <LINK rel="stylesheet" href="/style.css">. One may want to enclose the css within the style tags if you only have one page to access, but if you are using an FTP client to upload your website's files than save your css stylesheet separately near the same page as your index. Linking the stylesheet to your main page allows for quicker loading of your index page.
The way CSS works it is declares an element, like a bold tag, a div tag, etc and puts styles to it. Styles are declared before a : and ended with a ; So lets take a look at what a bold style might look like.
As you can see, the type is declared and then styles are listed within { and }. Some may styles may change colors of a text, change sizes, and font colors. Whereas styles for a div box may position it, add a border, change the font within it.
Properties
Here are some example of properties that may be declared:
body { } : Edits the page overall. You can declare a global background color or global font styles.
b { } : Edits the bold style.
i { } : Edits the italicized style.
u { } : Edits the underline style.
a:link { } : Edits a link style. After the : may be :visited to change the link after its been clicked on by the user, :hover changes the link when the user's mouse is over it, and :active changes the link to display whether or not it is broken.
h1 { } : Edits the header style.
#DIVNAME { } : Edits the your div (a box on the page). Interesting to note that it is listed with a #.
.CLASSNAME { } : Edits chunks of text within your body. Interesting to note that it is listed with a .
Here is a part of a style sheet I've done:
Now that we know how it is formatted, you have ALL the tools you need to build a webpage. To find all of your style options, check out this page and click on the property you are looking to edit.
There are two ways to put your CSS on the HTML page. You can either put it in <style></style> tags within the <head></head> tags, or you can link it in the <head></head> tags with <LINK rel="stylesheet" href="/style.css">. One may want to enclose the css within the style tags if you only have one page to access, but if you are using an FTP client to upload your website's files than save your css stylesheet separately near the same page as your index. Linking the stylesheet to your main page allows for quicker loading of your index page.
The way CSS works it is declares an element, like a bold tag, a div tag, etc and puts styles to it. Styles are declared before a : and ended with a ; So lets take a look at what a bold style might look like.
Code:
[COLOR="red"]b[/COLOR] {
font-weight:bold; [COLOR="Orange"]makes the text [B]bold[/B][/COLOR]
font-size:12px; [COLOR="Orange"]makes the text larger or smaller[/COLOR]
color:#FFFFFF; [COLOR="Orange"]makes the text a certain color[/COLOR]
}
Properties
Here are some example of properties that may be declared:
body { } : Edits the page overall. You can declare a global background color or global font styles.
b { } : Edits the bold style.
i { } : Edits the italicized style.
u { } : Edits the underline style.
a:link { } : Edits a link style. After the : may be :visited to change the link after its been clicked on by the user, :hover changes the link when the user's mouse is over it, and :active changes the link to display whether or not it is broken.
h1 { } : Edits the header style.
#DIVNAME { } : Edits the your div (a box on the page). Interesting to note that it is listed with a #.
.CLASSNAME { } : Edits chunks of text within your body. Interesting to note that it is listed with a .
Here is a part of a style sheet I've done:
Code:
[COLOR="Red"]body[/COLOR] {
background-color:white;
background-repeat:repeat-y;
margin:4px;
padding-top:4px;
padding-bottom:4px;
line-height:15px;
letter-spacing:0px;
color:#1D1D1D;
font-family:arial, sans-serif;
font-size:13px;
letter-spacing:1px;
cursor:default;
text-transform:none;
overflow:auto;
overflow-y: scroll;
overflow-x: hidden;
}
[COLOR="red"]h1[/COLOR] {
display:block;
background:#E3E2E2;
text-transform:uppercase;
font-family: 'Quicksand', sans-serif;
font-size:25px;
text-align:center;
font-weight:normal;
color:#FFFFFF;
letter-spacing:5px;
line-height:50px;
padding:0px;
margin-top:0px;
margin-bottom:0px;
}
[COLOR="red"]#main[/COLOR] {
top:300px;
width:100%;
background-color:white;
letter-spacing:0px;
padding:0px;
z-index:1;
margin:0 auto;
overflow:visible;
}
[COLOR="red"]A:LINK, A:HOVER, A:VISITED, A:ACTIVE[/COLOR] {
COLOR: #fcbe47;
text-decoration:none;
text-transform:none;
font-family:helvetica;
font-size:11px;
background-color: none;
font-weight:bold;
}
I have attached a css and index page example from my own personal portfolio website so you can see a real life example. Feel free to go through and resave these as style.css for the css page and index.php and upload them for examples, but they are currently just in .txt format.
Hope this helps everyone! Please let me know if you have any questions or if you'd like me to add anything!
Attachments
-
3.7 KB Views: 6
-
5 KB Views: 2
Last edited: