HTML


                   HTML BEGINNER TUTORIAL

THe thing to keep in mind is that HTML and CSS are all about separating the content (HTML) and the presentation (CSS). HTML is nothing more than fancy structured content and the visual formatting of that content will come later when we tackle CSS.
If you have looked at other HTML tutorials, you might have found that they mention certain things that HTML Dog does not. This is because many methods are obsolete, non-standard or just plain bad practice. Getting into the frame of mind of doing things the right way from the start will turn in to much better results in the end.
           

Getting Started

Most of the stuff on the web is no different than the stuff on your computer - it's just a whole load of files sorted into a whole load of directories.
HTML files are nothing more than simple text files, so to start writing in HTML, you need nothing more than a simple text editor.
Changes are afoot…10
Follow HTML Dog on Twitter@htmldog on Twitter
Notepad is a common text editor (on Windows this is usually found under the Programs > Accessories menu).
Type this in to your text editor:

This is my first web page
Now create a folder called 'html' in your C drive (or anywhere else you fancy) and save the file as "myfirstpage.html". It is important that the extension ".html" is specified - some text editors, such as Notepad, will automatically save it as ".txt" otherwise.
To look at HTML files, they don't even need to be on the web. Open a web browser such as Firefox or Internet Explorer and in the address bar, where you usually type web addresses, type in the location of the file you just saved (for example, "c:\html\myfirstpage.html") and hit return. Alternatively, go to the File menu of the browser, select Open, and browse for the file.
Pow. There it is. Your first web page. How exciting. And all it took was a few typed words.
We've said here to use a basic text-editor, such as Notepad, but you may be tempted to use a dedicated software program such as Macromedia Dreamweaver orMicrosoft Frontpage.
You should be very careful when using these programs, especially if you are a beginner, because they often throw in unnecessary or non-standard code to "help" you.
If you're serious about learning HTML, you should read through a tutorial such as this first, so that you at least have a basic understanding of what is going on.
Software programs such as these will never give you the same control over a web page as coding by hand.

Tags

The basic structure of an HTML document includes tags, which surround content and apply meaning to it.
Change your document so that it looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<body>
 This is my first web page
</body>
</html>
Now save the document again, go back to the web browser and select "refresh" (which will reload the page).
The appearance of the page will not have changed at all, but the purpose of HTML is to apply meaning, not presentation, and this example has now defined some fundamental elements of a web page.
The first line on the top that starts <!DOCTYPE... is to let the browser know that you know what the hell you're doing. You may think that you don't actually know what you're doing yet, but it's important to stick this in. If you don't, browsers will switch into "quirks mode" and act in a very peculiar way. Don't worry about this just yet, you can learn more about "document types" in the HTML Advanced Tutorial if you really want to. For the moment, just remember to shove this line at the top of your web pages and you're laughin'.
To get back to the point, <html> is the opening tag that kicks things off and tells the browser that everything between that and the </html> closing tag is an HTML document. The stuff between <body> and </body> is the main content of the document that will appear in the browser window.

Closing tags

The </body> and </html> close their respective tags. ALL HTML tags should be closed. Although older versions of HTML lazily allowed some tags not to be closed, latest standards require all tags to be closed. This is a good habit to get into anyway.
Not all tags have closing tags like this (<html></html>) some tags, which do not wrap around content will close themselves. The line-break tag for example, looks like this :<br />. We will come across these examples later. All you need to remember is that all tags must be closed and most (those with content between them) are in the format of opening tag → content → closing tag.

Attributes

Tags can also have attributes, which are extra bits of information. Attributes appear inside the opening tag and their value is always inside quotation marks. They look something like <tag attribute="value">Margarine</tag>. We will come across tags with attributes later.

Elements

Tags tend not to do much more than mark the beginning and end of an element. Elements are the bits that make up web pages. You would say, for example, that everything that is in-between and includes the <body> and </body> tags is the body element. As another example, whereas '<title>' and '</title>' are tags, '<title>Rumple Stiltskin</title>' is a title element

TITLES

To add a title to your page, change your code so that it looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
 <title>My first web page</title>
</head>

<body>
 This is my first web page
</body>

</html>
We have added two new elements here, that start with the head tag and the title tag (and see how both of these close).
The head element (that which starts with the <head> opening tag and ends with the </head> tag) appears before the body element (starting with <body> and ending with</body>) and contains information about the page. The information in the head element does not appear in the browser window.
We will see later on that other elements can appear inside the head element, but the most important of them is the title element.
If you look at this document in the browser (save and refresh as before), you will see that "My first web page" will appear on the title bar of the window (not the actual canvas area). The text that you put in between the title tags has become the title of the document (surprise!). If you were to add this page to your 'favourites' (or 'bookmarks', depending on your browser), you would see that the title is also used there.

No comments:

Post a Comment