The Internet
Digest |
||||||||||||||||||||||||||||
HTML TutorialBasicsMost web pages are created using HTML HTML stands for Hyper Text Markup Language so an web/HTML file is a text file containing MARKUP. MARKUP is a method of telling a web browser how to display a page - which text is to be underlined or bold etc. HYPER TEXT refers to the fact that you can link HTML pages together in such a way that you can jump form one page to the next. You can create HTML pages using a text editor such as Notepad. Don't try and use a word processor such as Microsoft's Word. It isn't suitable. Open your text editor and type (or copy 'n' paste) the following:
Save the file as firstpage.html. Now, either:
You should now see your first web page. Congratulations! Explanation:All web pages are basically comprised of two sort of information:
Markup instructions, or ELEMENTS, are held in 'tags'. A web browser can differentiate between Content and Markup because each 'tag' starts with a '<' and ends with a '>'. Each ELEMENT can also have ATTRIBUTES associated with it which supply additional information if needed. You'll be meeting ATTRIBUTES when we look at adding images to web pages So, let's go through your first page and see what all those tags did. For a start, notice that all the tags are in lower-case. Some of the older forms of HTML did allow for upper-case tags, however, the World Wide Web Consortium (W3C) - the international body that sets the guidelines for HTML Markup - has declared that lowercase tags are mandatory for XHTML. As this is the newest form of HTML Markup, it would be a good idea to stick to lower-case tags right from the start. Next, note that all of the tags come in pairs:
With few exceptions, all tags have both opening and closing forms. You should get into the habit of including both types. <html></html>The first line in your HTML document is <html>. All web pages must begin with a <html> and end with a </html>. <html> is an opening tag </html> is a closing tag. So <html> told the browser that we are opening an HTML document and </html> told the browser that we were closing our HTML document. <head></head>The text between these two tag is called Header Information. Header information is not displayed in a web page itself but can contain information about the page such as information for search engines etc. <title></title>You place the title for your web page between these two tags and it will be displayed in the top bar of the browser window. <body></body>The text between the <body></body> tags is the all of the text that you want to be displayed in a browser window. In other words, the actual displayed web page. <p></p>These paragraph tags are called BLOCK ELEMENTS as they are used to enclose whole blocks of text. Text to be displayed should always be placed between two, BLOCK ELEMENT tags. <strong></strong>Text placed between these tags will be displayed in a bold font. <em></em>Text placed between these tags will be displayed in italics. Mixing, or nesting, tagsNotice how you were able to have bold and italic text by using both the <strong></strong> and <em></em> tags? Take a closer look at the code for that last displayed line.
See how the first tag opened is always the last tag closed? This is known as nesting and refers to the fact that, if you use a number of tags
together, you must always close them in the reverse order that you opened them. Page HeadingsOpen up your web page in a text editor. You should see the following:
Now, immediately after the <body> tag, press the ENTER key and then type in the following:
You should now see:
Resave your web page and then view it in your web browser. If you still have it loaded in the browser window just select Refresh to view the updated version. You have just added a page heading! HeadingsThere are 6 heading tags in HTML. They are numbered <h1>,<h2>,<h3>,<h4>,<h5> and <h6> Each one is accompanied with their respective closing tags(eg. <h1>...</h1> etc. This is an h1 heading!This is an h2 heading!This is an h3 heading!This is an h4 heading!This is an h5 heading!This is an h6 heading!Whenever you use a heading tag, the browser automatically adds an extra blank line before and after the displayed heading text. Try this:
Play around with different heading tags to get a feel for the displayed text
size. Line BreaksThe <br /> tag is used when you want to end a line, but don't want to start a new paragraph. The <br /> tag forces a line break wherever you place it. Unlike most of the other tags, <br /> has no closing tag so the closing '/' has been combined into the opening tag to make a composite, or empty, tag. Have a look and see how it works: <html> Note: The <br /> tag is an INLINE ELEMENT which means that it must always be used inside a pair of BLOCK ELEMENT tags (such as <p></p> or similar)! Comments in HTMLYou can add comments to your HTML Markup. These can be useful when your page becomes very large or complex and you need to insert small markers to remind you what each part of the markup is for. You can insert a comment by starting it with a <!-- and ending the comment with a --> Anything between these two comment markers will not be displayed by a web browser
Horizontal RulesNow try this:
You have added a horizontal rule by using the <hr /> tag after your first heading. Note that, like <br />, the horizontal rule tag is a composite tag.
Special CharactersSome text for display cannot be entered directly into an HTML document - such as & or £. Instead these symbols must be entered using CHARACTER ENTITIES. A character entity has three parts:
For example: To display < in a web page when it is not meant to be part of the markup, you must use < To display > in a web page when it is not meant to be part of the markup, you must use > To display " in a web page when it is not meant to be part of the markup, you must use " Common Character Entities:
Adding Colour or wallpaperRemember the Header section <head></head> tags in our example page that we've ignored so far? Well, we're about to start adding information here. The information we are going to add will relate to the way we want our page displayed - what background colour the page should have; what colour the text should be etc. This sort of information is known as the page STYLE and can eiither be stored inside the web page markup itself or as a separate file. We'll be using the former method for now. Open up your example web page in a text editor.
Now add the following immediately BEFORE the </head> tag:
Your markup should now look like this:
Now view the page in your web browser. The background should now be a plain, pale green and the text is very dark green. So, how did we do this? <style></style>The opening tag <style> tells the browser that it is about to receive some information relating to colour and text formatting. The addition of "type=text/css" tells it what form that information will be in. CSS is short for Cascading Style Sheet - the W3C recommended method for incorporating such information into a web page. Like most tags, there is an appropriate closing tag (</style>) to indicate when we've finshed supplying this information. Inside the <style></style> tagsAll style information follows the same format. First you tell the browser what part of the page you intend to describe. In our case, we are describing everything between the <body> </body> tags, so we begin by using the word: body The rest of the information gives specific instructions to the browser on what sort of display we want and is always enclosed between { and }. Each line should include a single 'item', a colon (:), a space (for human readability), the colour or formatting information and, finally, a semi-colon (;). For example:
This tells the browser that the background of all text is to be set to pale green. Colours are referred to using hexidecimal codes ie a # followed by six letter and, or, numbers. You can find a list of colours and their associated codes here.
This tells the browser that all text is to be displayed in dark green. Note the spelling of 'color' rather than 'colour'. Add this altogether and you should end up with:
WallpaperYou can have a wallpaper/image background for your web page but be careful that it doesn't make the text difficult to read! Download this background file by rightclicking the link and selecting Save Target As.. and place it in the same folder as your web page. Edit your style information as follows:
Save and view your web page. You should now have a lightly patterned, yellow,
background! GraphicsIn HTML, images are defined with the <img> tag. The <img> ELEMENT has a composite tag, which means that one tag contains all the attributes and the closing slash (/). To display an image on a page, you need to use the SRC ATTRIBUTE. src is an abbreviation of "source". The value of the src attribute is the URL (location) of the image you want to display on your page. The syntax of defining an image is as follows:
The location should be the web address where the image is stored. For example, this image: is in the main images folder on Black Widow's site and is defined in the markup for this page as:
The browser places the image where the image tag occurs in the markup of the document. If you place an image in your first paragraph markup, it will be displayed in the first paragraph. If you place it in the second paragraph markup, it will be displayed in the second paragraph etc. All images should always be placed with BLOCK ELEMENTS such as <p></p> tags Note: Images can be useful in decorating a web page or provide additoinal information in themselves, However, every images you place in an HTML document will need to be downloaded before your page can be displayed properly. Loading images take time, so use images sparingly. WarningWhen adding images, do not be tempted to link directly to other people's images on
their site to display on your web pages. This is known as Bandwidth Theft and can be
viewed as serious abuse. After ensuring that you are allowed to copy such an image (if
neccessary email the site owner), save a copy on your own site and link to it there. LinksThe <a> Tag and the href AttributeHTML markup uses the <a> (the link or anchor) tag to create a link to another document. An link can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc. The syntax of creating a link is as follows:
Link markup should always be placed inside a BLOCK ELEMENT such as between <p></p> tags. Links inside documentsYou can create links inside long documents to allow people to move straight to a particular sub-section. To create such links, first place a reference anchor at the point you want people to jump to your markup and then place a link to allow people to jump to that point. For example, the following markup is placed at the top of this page:
And this link will allow you to jump straight to the top of the page by using:
Right click on this page and select View Page Source to see if you can locate these particular pieces of markup. Email LinksLet's say you want to enter an email address, foo@bar.com, and make it clickable. The syntax for this would be:
The URI inside the <a> tag is is the email address you want to link to. The text surrounded by the <a> and </a> is the link text that you want displayed on your page. So if Joe Smith's email address is joe@bar.com, you could use:
|
||||||||||||||||||||||||||||