I am going to take a moment and try to give you some basics of coding.
HTML Cheat Sheet
The first thing you have to do is ensure you have all the correct elements present when creating a page to be displayed on the internet.
HTML Elements:
<html>
<head>
<title>Title of page</title>
</head>
<body>
This is my first homepage. <b>
This text is bold</b>
</body>
</html>
Example Explained
The first tag in your HTML document is <html>. This tag tells your browser that this is the start of an HTML document. The last tag in your document is </html>. This tag tells your browser that this is the end of the HTML document.
The text between the <head> tag and the </head> tag is header information. Header information is not displayed in the browser window.
The text between the <title> tags is the title of your document. The title is displayed in your browser's caption, at the very top of the browser window.
The text between the <body> tags is the text that will be displayed in your browser.
The text between the <b> and </b> tags will be displayed in a bold font.
Notice
For every tag listed above, there was an opening tag and a closing tag. For example, the bold tag that created the bold text. There was an opening <b>, then some text followed by a closing tag, or rather, </b>.
It is extremely important you close all open tags!
I would also like to add that you should always use lowercase tags in your code. Yes, you will find many sites that use uppercase tags, like this <B>, but If you want to follow the latest web standards, you should always use lowercase tags. The World Wide Web Consortium (W3C) recommends lowercase tags in their HTML 4 recommendation, and XHTML (the next generation HTML) demands lowercase tags.
Let's continue . . .
The most important tags in HTML are tags that define headings, paragraphs and line breaks.
The best way to learn HTML is to work with examples. Thanks to the W3C, they have created a very nice HTML editor for you. With this editor, you can edit the HTML source code if you like, and click on a test button to view the result.
Try it Yourself - Examples
A very simple HTML document
This example is a very simple HTML document, with only a minimum of HTML tags. It demonstrates how the text inside a body element is displayed in the browser.
Simple paragraphs
This example demonstrates how the text inside paragraph elements is displayed in the browser.
Headings
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6> defines the smallest heading.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6>This is a heading</h6>
HTML automatically adds an extra blank line before and after a heading.
Paragraphs
Paragraphs are defined with the <p> tag.
<p>This is a paragraph</p>
<p>This is another paragraph</p>
HTML automatically adds an extra blank line before and after a paragraph.
Don't Forget the Closing Tag
You might have noticed that paragraphs can be written without end tags </p>:
<p>This is a paragraph
<p>This is another paragraph
The example above will work in most browsers, but don't rely on it. Future version of HTML will not allow you to skip ANY end tags.
Closing all HTML elements with an end tag is a future proof way of writing HTML. It also makes the code easier to understand (read and browse) when you to mark both where an element starts and where it ends.
Line Breaks
The <br> tag is used when you want to break a line, but don't want to start a new paragraph. The <br> tag forces a line break wherever you place it.
<p>This <br> is a para<br>graph with line breaks</p>
Try it yourself
The <br> tag is an empty tag. It has no end tag like </br>, since a closing tag doesn't make any sense.
<br> or <br />
More and more often you will see the <br> tag written like this: <br />
Because the <br> tag has no end tag (or closing tag), it breaks one of the rules for future HTML (the XML based XHTML), namely that all elements must be closed.
Writing it like <br /> is a future proof way of closing (or ending) the tag inside the opening tag, accepted by both HTML and XML.
Comments in HTML
The comment tag is used to insert a comment in the HTML source code. A comment will be ignored by the browser. You can use comments to explain your code, which can help you when you edit the source code at a later date.
<!-- This is a comment -->
Note that you need an exclamation point after the opening bracket, but not before the closing bracket.
Basic Notes - Useful Tips
When you write HTML text, you can never be sure how the text is displayed in another browser. Some people have large computer displays, some have small. The text will be reformatted every time the user resizes his window. Never try to format the text in your editor by adding empty lines and spaces to the text.
HTML will truncate the spaces in your text. Any number of spaces count as one. Some extra information: In HTML a new line counts as one space.
Using empty paragraphs <p> to insert blank lines is a bad habit. Use the <br> tag instead. (But don't use the <br> tag to create lists. Wait until you have learned about HTML lists.)
HTML automatically adds an extra blank line before and after some elements, like before and after a paragraph, and before and after a heading.
More Examples
More paragraphs
This example demonstrates some of the default behaviors of paragraph elements.
Line breaks
This example demonstrates the use of line breaks in an HTML document.
Poem problems
This example demonstrates some problems with HTML formatting.
Headings
This example demonstrates the tags that display headings in an HTML document.
Horizontal rule
This example demonstrates how to insert a horizontal rule.
Hidden comments
This example demonstrates how to insert a hidden comment in the HTML source code.
Text Formatting Tags
Tag Description
<b> Defines bold text
<u> Defines underline text
<big> Defines big text
<em> Defines emphasized text
<i> Defines italic text
<small> Defines small text
<strong> Defines strong text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
Let me add . . .
I can not possibly list every single tag that is available, so if you want to jump ahead, here is a link to a really good
HTML Quick List.
Do You Want to Try It?
If you are running Windows, start Notepad.
If you are on a Mac, start SimpleText.
In OSX start TextEdit and change the following preferences: Open the the "Format" menu and select "Plain text" instead of "Rich text". Then open the "Preferences" window under the "Text Edit" menu and select "Ignore rich text commands in HTML files". Your HTML code will probably not work if you do not change the preferences above!
Type in the following text (copy/paste should work also):
Code:
<html>
<head>
<title>Example Page</title>
</head>
<body>
<h1>My Example Page</h1>
<p>Hello there.</p>
Some text here <br />
and some more
</body>
</html>
Save the file as "mypage.htm".
Start your Internet browser. Select "Open" (or "Open Page") in the File menu of your browser. A dialog box will appear. Select "Browse" (or "Choose File") and locate the HTML file you just created - "mypage.htm" - select it and click "Open". Now you should see an address in the dialog box, for example "C:\MyDocuments\mypage.htm". Click OK, and the browser will display the page.
Congratulations, you have created your very first webpage!
Now I'm certain you want to do more to your page, for instance say you want to add a picture!
This requires the <img> tag. Makes sense doesn't it? image = img !!!
Anyway, to add an image you need a few things first. I'll write a correctly written link to an image and then I'll explain it.
<img src="http://i.imgur.com/F0m0Ckz.png" width="32" height="32" border="0" alt="Star" />
<img = begin our image tag
src = where to get our image
width = width of image
height = height of image
border = 0 means none, 1 and on is thickness with the border increasing as does the number
alt = text to show if you don't show the picture
/> = the image tag is a self closing tag, just like the <br /> tag is
When it's all put together correctly, you will show:
But where to put this image code? In your example page you created, mypage.htm, you can place it almost anywhere, between the <body></body> tags.
Preferably, not in the middle of heading tags, however!
Now what if you want to put a text link to another page on your site. Well, let's not stop now, we've come so far now!
Again, let me code a correct link, and then I'll explain it:
<a href="http://www.tierrahosting.com" title="Tierra Hosting">Tierra Hosting</a>
<a = start of the tag, referred to as an Anchor tag
href = the address your linking to
title = suggested title for the document to be opened
</a> = closing tag for the anchor, unlike the <img> tag, an anchor is NOT self closing
When put all together correctly, you'll end up with:
Tierra Hosting
being displayed on your webpage.
As with all the tags of HTML, there are many (and I mean MANY) variables that you can add to modify your code. For instance, with the above anchor/link code I wrote I could of modified it with any of the following:
target="_blank" --> opens linked address in new window
target="_parent" --> works like "_top", but I don't recommend "_parent"
taget="_self" --> opens linked address in this (current) window (same as if you used no target='s at all)
target="_top" --> opens linked address in same window on top of anything being displayed
Overall, I hope you visit the
HTML Quick List to get a better grasp on your HTML.
I will post again next time on how to create tables and position of them on your new webpage.
Until next time . . .