HTML Basics
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>
My Home Page
</title>
</head>
<body>
<h1>My Home Page </h1>
<p>
Welcome to my home page
</p>
</body>
</html>
|
DOCTYPE Declares the type of HTML/XHTML being used. HEAD Contains information about the page as a whole. |
|
BODY Everything that will appear in the browser display window. |
You prepare a document in HTML by creating a plain text file containing your text, adding mark-up tags to indicate the role of each block of text, and then using styles to how the blocks will be displayed.
- Any Text Editor Will Do
HTML files can be prepared with any text editor and with many word processors. If you do use a word processor, be sure to save the file as "plain text" or "plain text with line breaks." - Begin With a DOCTYPE Statement The DOCTYPE statement declares which version of HTML you are using, which will make it easier for any program reading your page to understand it.
-
Two Parts
An HTML file consists of two parts, a head and a body.- The head contains commands that apply to the whole document, such as the document title.
- The body contains everything that will be displayed by the browser.
- Begin Tags And End Tags
Most HTML tags are in pairs, a begin tag and an end tag. For example, <b> is put at the beginning of text that you want bolded and </b> is put at the end to turn off the bolding. Some HTML tags, called "empty tags," do not have content and therefore do not have end tags. In XHTML, these empty tags contain a backslash. For example, in HTML a horizontal rule is created with a <hr> tag and in XHTML it is created with a <hr /> tag. - Case Sensitive
HTML tags should always be in lower case. - Extra Spaces And Blank Lines
Extra blank spaces and blank lines in the HTML file are ignored when the document is displayed. Several spaces are the same as one space. Several lines are the same as one line. You can use extra spaces and blank lines in your HTML to make it easier to understand and maintain.