Académique Documents
Professionnel Documents
Culture Documents
Learne HTML
By ExccC for R00tw0rm Members
ExccC r00tw0rm
HTML Elements
An element consists of three basic parts: an opening tag, the element's content, and finally, a closing tag. 1. <p> - opening paragraph tag 2. Element Content - paragraph words 3. </p> - closing tag Every (web) page requires four elements: the html, head, title, and body elements.
HTML Code:
<html> </html>
This page will show "My WebPage!" in the upper-left, as the window's title.
Tags should be lower-case letters if you plan on publishing your work. This is the standard for XHTML and Dynamic HTML. Here's quick look at some HTML tags.
HTML Tags:
<body>Body Tag (acts as a content shell) <p>Paragraph Tag</p> <h2>Heading Tag</h2> <b>Bold Tag</b> <i>Italic Tag</i>
</body>
HTML Code:
<br />
To tell the browser we want to place a line break onto the site, it is not necessary to type <br>linebreak</br>. Instead the better solution was to combine the opening and closing tags into a single format. Other tags have also been modified such as the image tag and input tag.
HTML Code:
<img src="../mypic.jpg" /> -- Image Tag <br /> -- Line Break Tag <input type="text" size="12" /> -- Input Field
Display:
As you can see from the above image tag, your browser is completely capable of interpreting this tag so long as we tell the browser where the image is located using the src attribute.
HTML - Attributes
Attributes are used to amplify tags. What we mean by amplify is that when a web browser interprets a tag, it will also search for set attributes and then display the element (tags+attributes) in its entirety. At some point you may want to give your body element a background color or perhaps change the width of a table. All of these things and more can be achieved using Attributes.
HTML Code
<p id="italicsparagraph">Paragraph type 1 Italics</p> <p id="boldparagraph">Paragraph type 2 Bold</p>
Classification Attributes
Paragraph type 1 Italics Paragraph type 2 Bold
HTML Code:
<input type="text" name="TextField" />
This attribute has no effect on the display of the text field, but behind the scenes it plays a huge identification role.
HTML Code
<h2 align="center">Centered Heading</h2>
Display:
Centered Heading
HTML Code
<h2 align="left">Left aligned heading</h2> <h2 align="center">Centered Heading</h2> <h2 align="right">Right aligned heading</h2>
Display
Left aligned heading Centered heading Right aligned heading
Attribute
Attribute align valign bgcolor background id class width height title Options Function right, left, center Horizontally aligns tags top, middle, bottom Vertically aligns tags within an HTML element. numeric, hexidecimal, RGB values Places a background color behind an element URL Places an background image behind an element User Defined Names an element for use with Cascading Style Sheets. User Defined Classifies an element for use with Cascading Style Sheets. Numeric Value Specifies the width of tables, images, or table cells. Numeric Value Specifies the height of tables, images, or table cells. User Defined "Pop-up" title for your elements.
HTML Code:
<p>Avoid losing floppy disks with important school...</p> <p>For instance, let's say you had a HUGE school...</p>
HTML Code:
<p align="justify">let's say you had a HUGE school or work...</p> <p align="center">let's say you had a HUGE school or work...</p> <p align="right">let's say you had a HUGE school or work...</p>
HTML Code:
<body> <h1>Headings</h1> <h2>are</h2> <h3>great</h3> <h4>for</h4> <h5>titles</h5> <h6>and subtitles</h6> </body>
Display
Headings
are
great
for
titles
and subtitles
Each heading has a line break before and after each heading display.
Line Breaks
Line breaks are different then most of the tags we have seen so far. A line break ends the line you are currently on and resumes on the next line.
HTML Code:
<p> Will Mateson<br /> Box 61<br /> </p>
Address:
Will Mateson Box 61 We have created a possible address for a letter head. The line break tag will also come in handy toward the end of our letter.
HTML Code
HTML <hr /> JAVASCRIPT
Display
HTML JAVASCRIPT
HTML Lists
There are 3 different types of lists. <ul> - unordered list; bullets <ol> - ordered list; numbers <dl> - definition list; dictionary Use the type and start attributes to fine tune your lists accordingly.
HTML Code:
Goals <ol start="4"> <li>Find a Job</li> <li>Get Money</li> <li>Move Out</li> </ol>
Numbered list:
Goals
4. Find a Job 5. Get Money 6. Move Out Start your ordered list on any number besides 1 using the start attribute.
HTML Code:
<ol <ol <ol <ol type="a"> type="A"> type="i"> type="I">
HTML Code:
Shopping List <ul> <li>Milk</li> <li>Toilet Paper</li> <li>Cereal</li> <li>Bread</li> </ul>
Unordered Lists:
Shopping List
Milk Toilet Paper Cereal Bread Here's a look at the other flavors of unordered lists may look like.
HTML Code:
<ul type="square"> <ul type="disc"> <ul type="circle">
HTML Code:
<dl> <dt><b>Fromage</b></dt> <dd>French word for cheese.</dd> <dt><b>Voiture</b></dt> <dd>French word for car.</dd> </dt></dl>
HTML Code:
Fromage French word for cheese. Voiture French word for car.
HTML Formatting:
An example of Bold Text An example of Emphasized Text
An example of Strong Text An example of Italic Text An example of superscripted Text An example of subscripted Text An example of An example of Computer Code Text
My First Hexadecimal:
bgcolor="#RRGGBB"
A Real Hexadecimal:
bgcolor="#FFFFFF"
The letter "F" is the maximum amount we can send each color and as you may deduce, this color (#FFFFFF) represents the color white. A formula exists to calculate the numeric equivalent of a hexadecimal.
Hexadecimal Formula:
(15 * 16) + (15) = 255
The formula is real simple. Take the first value (F) or 15 multiply it by 16 and add it to the second value, 15. The value 255 is the maximum allowed for any primary color. Let's try another one.
Example 2:
bgcolor="#CC7005" CC(RR - Red) (12 * 16) + (12) = 204 70(GG - Green) (7 * 16) + (0) = 112 05(BB - Blue) (0 * 16) + (5) = 5
Hexadecimals are the best choice for compatible web development because of their consistency between browsers. Even the most minor of change in color can throw your entire site. If you want to be absolutely sure your colors will not change, use paired hex values for color. Examples: "#0011EE", "#44HHFF", or "#117788". These are called True Colors, since they will stay true from browser to browser.
Font Size
Set the size of your font with size. The range of accepted values is from 1(smallest) to 7(largest).The default size of a font is 3.
<p> <font size="5">Here is a size 5 font</font> </p>
Display
Here is a size 5 font.
Font Color
Set the color of your font with color.
<font color="#990000">This text is hexcolor #990000</font> <font color="red">This text is red</font>
Display
This text is hexcolor #990000 .This text is red
Font Face
Choose a different font face using any font you have installed. Be aware that if the user viewing the page doesn't have the font installed, they will not be able to see it. Instead they will default to Times New Roman.
<p> <font face="Bookman Old Style, Book Antiqua, Garamond">This paragraph has had its font...</font> </p>
Display
This paragraph has had its font formatted by the font tag!
Display
This paragraph has had its font formatted by the basefont tag! This paragraph has had its font formatted by the basefont tag! This paragraph has had its font formatted by the basefont tag!
Display
Code
<a href="http://www.tizag.com/" target="_blank" >Tizag Home</a> <a href="http://www.espn.com/" target="_self" >ESPN Home</a> <a href="http://www.yahoo.com/" target="_blank" >Yahoo Home</a>
Global Link:
Tizag Home ESPN Home Yahoo Home
HTML Code:
target=" _blank" Opens new page in a new browser window _self" Loads the new page in current window _parent" Loads new page into a frame that is superior to where the link lies _top" Loads new page into the current browser window, canceling all frames
HTML - Anchors
To link to sections of your existing page a name must be given to the anchor.
Code:
<h2>HTML Links and Anchors<a name="top"></a></h2> <h2>HTML Text Links<a name="text"></a></h2> <h2>HTML Email<a name="email"></a></h2>
Now create the reference links, placing the pound symbol followed by the name of the anchor in the href of the new link.
Anchor Code:
<a href="#top">Go to the Top</a> <a href="#text">Learn about Text Links</a>
Local Links:
Go to the Top Learn about Text Links
HTML Code:
<a href="mailto:email@abc.com?subject=Feedback" >Email@abc.com</a>
Email Links:
Email@abc.com In some circumstances it may be necessary to fill in the body of the Email for the user as well.
HTML Code:
<a href="mailto:email@abc.com?subject=Feedback&body=Sweet site!"> Email@abc.com</a>
Complete Email:
Email@abc.com
HTML Code:
<a href="http://www.abc.com/pics/htmlT/blanktext.zip">Text Document</a>
HTML Code:
<head> <base href="http://www.abc.com/"> </head>
Here's an example.
HTML Code:
<p>Everything that goes up, must come down!</p>
Spaces:
Everything that goes up, must come down! In HTML we use less than and greater than characters to create tags, so to use them on your web site you will need entities.
HTML Code:
<p> Less than - < <br /> Greater than - > <br /> Body tag - <body> </p>
HTML - Images
Use the <img /> tag to place an image on your web page.
HTML Code:
<img src="sunset.gif" />
Image:
HTML Code:
<img src="http://example.com/brokenlink/sunset.gif" alt="Beautiful Sunset" />
Alternative Text:
To define the height and width of the image, rather than letting the browser compute the size, use the height and width attributes.
HTML Code:
<img src="sunset.gif" height="50" width="100">
HTML Code:
<img src="sunset.gif" align="right"> The image will appear along the...isn't it?
Images as Links
This will be a quick review of the links - image lesson. Images are very useful for links and can be created with the HTML below.
HTML Code:
<a href="http://www.abc.com/"> <img src="sunset.gif"> </a>
Image Links:
Now your image will take you to our home page when you click it. Change it to your home page URL.
HTML Code:
<a href="http://www.espn.com" target="_blank"> <img src="ahman.gif"> </a>
Image Link:
HTML Forms
Forms are a vital tool for the webmaster to receive information from the web surfer, such as: their name, email address, credit card, etc. A form will take input from the viewer and depending on your needs, you may store that data into a file, place an order, gather user statistics, register the person to your web forum, or maybe subscribe them to your weekly newsletter.
Text Fields
Before we teach you how to make a complete form, let's start out with the basics of forms. Input fields are going to be the meat of your form's sandwich. The <input> has a few attributes that you should be aware of. type - Determines what kind of input field it will be. Possible choices are text, submit, and password. name - Assigns a name to the given field so that you may reference it later. size - Sets the horizontal width of the field. The unit of measurement is in blank spaces. maxlength - Dictates the maximum number of characters that can be entered.
HTML Code:
<form method="post" action="mailto:youremail@email.com"> Name: <input type="text" size="10" maxlength="40" name="name"> <br /> Password: <input type="password" size="10" maxlength="10" name="password"> </form>
Input Forms:
Name: Password: Do not use the password feature for security purposes. The data in the password field is not encrypted and is not secure in any way.
HTML Code:
<form method="post" action="mailto:youremail@email.com"> Name: <input type="text" size="10" maxlength="40" name="name"> <br /> Password: <input type="password" size="10" maxlength="10" name="password"><br /> <input type="submit" value="Send"> </form>
Email Forms:
Name: Password: Simply change the email address to your own and you will have set up your first functional form!
name - defines which set of radio buttons that it is a part of. Below we have 2 groups: shade and size.
HTML Code:
<form method="post" action="mailto:youremail@email.com"> Shade: <input type="radio" name="shade" value="dark">Dark <input type="radio" name="shade" value="light">Light <br /> </form>
Radios:
Shade: Dark Light
HTML Code:
<form > <input type="checkbox" name="toon" value="aaa">Goofy <input type="checkbox" name="toon" value="bbb">Donald <input type="checkbox" name="toon" value="ccc">Bugs Bunny <input type="checkbox" name="toon" value="ddd">Scooby Doo </form>
Check Boxes:
aaabbbcccddd
HTML Code:
<form > <select name="degree"> <option>Choose One</option> <option>Some High School</option> <option>High School Degree</option> </select> </form>
Selection Forms:
In this field, the user has the option to type in the full local URL of the file or he/she may click the browse button to thumb through directory after directory. HTML codes this automatically when we place the type="file" attribute within the input tag.
HTML Code:
<input type="hidden" name="MAX_FILE_SIZE" value="100" /> <input name="file" type="file" />
Upload Form:
HTML Code:
<form > <textarea rows="5" cols="20" wrap="physical" name="comments"> Enter Comments Here </textarea></form>
Also note that any text placed between the opening and closing textarea tags will show up inside the text area when the browser views it.
HTML Tables
The <table> tag is used to begin a table. Within a table element are the <tr> (table rows) and <td> (table columns) tags.
<table border="1"> <tr><td>Row 1 Cell 1</td><td>Row 1 Cell 2</td></tr> <tr><td>Row 2 Cell 1</td><td>Row 2 Cell 2</td></tr> </table>
Basic Table:
Row 1 Cell 1 Row 1 Cell 2 Row 2 Cell 1 Row 2 Cell 2 Content is placed within tables cells. A table cell is defined by <td> and </td>.The border attribute defines how wide the table's border will be.
HTML Code:
<table border="1">
<tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> <tr><td rowspan="2">Row 1 Cell 1</td> <td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr> <tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr> <tr><td colspan="3">Row 3 Cell 1</td></tr> </table>
HTML Code:
<table border="1" cellspacing="10" bgcolor="rgb(0,255,0)"> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr><td>Row 1 Cell 1</td><td>Row 1 Cell 2</td></tr> <tr><td>Row 2 Cell 1</td><td>Row 2 Cell 2</td></tr> </table>
HTML Code:
<table border="1" cellpadding="10" bgcolor="rgb(0,255,0)"> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr><td>Row 1 Cell 1</td><td>Row 1 Cell 2</td></tr> <tr><td>Row 2 Cell 1</td><td>Row 2 Cell 2</td></tr> </table>
Cell Pads:
Column 1 Row 1 Cell 1 Row 2 Cell 1 Column 2 Row 1 Cell 2 Row 2 Cell 2
The value you specify for padding and spacing is interpreted by the browser as a pixel values you. So a value of 10 is simply 10 pixels wide. Most attributes that use numeric values for their measurements use pixels.
The bgcolor attribute is used to control the background of an HTML elmement, specifically page and table backgrounds. Bgcolor can be placed within several of the HTML tags
Syntax
<TAGNAME bgcolor="value">
HTML Code:
<body bgcolor="Silver"> <p>We set the background...</p> </body>
HTML Code:
<table bgcolor="lime" border="1"><tr> <td>A lime colored table background using color names.</td> </tr></table> <table bgcolor="#ff0000" border="1"><tr> <td>A red colored table background using hexadecimal values "#FF0000".</td> </tr></table> <table bgcolor="rgb(0, 0, 255)" border="1"><tr> <td>A blue colored table background using RGB values "rgb(0, 0, 255)".</td> </tr></table>
Table Bgcolors:
A lime colored table background using color names. A red colored table background using hexadecimal values "#FF0000". A blue colored table background using RGB values "rgb(0, 0, 255)".
HTML Code:
<table bgcolor="#000000"> <tr><td bgcolor="#009900"> <font color="#FFFF00" align="right">Green Bay</font></td> <td><font color="#FFFFFF">13</font></td></tr> </table>
Scoreboard:
Green Bay 13
HTML - Background
Images can be placed within elements of HTML. Tables, paragraphs, and bodys may all have a background image. To accomplish this, we use the background attribute as follows.
HTML Code:
<table height="100" width="150" background="background.jpg" > <tr><td>This table has a background image</td></tr> </table>
Background Image:
This table has a background image
HTML Code:
<table height="200" width="300" background="background.jpg" > <tr><td>This table has a background image</td></tr> </table>
Repeating Background:
This table has a background image
HTML Frames
Frames allow for multiple ".html" documents to be displayed inside of one browser window at a time.
HTML Code:
<html> <head> </head> <frameset cols="30%,*"> <frame src="menu.html"> <frame src="content.html"> </frameset> </html>
Frame Set:
Here's the example: Frame Index frameset - The parent tag that defines the characteristics of this frames page. Individual frames are defined inside it. frameset cols="#%, *"- Cols(columns) defines the width that each frame will have. In the above example we chose the menu (the 1st column) to be 30% of the total page and used a "*", which means the content (the 2nd column) will use the remaining width for itself. frame src="" -The location of the web page to load into the frame. A good rule of thumb is to call the page which contains this frame information "index.html" because that is typically a site's main page.
HTML Code:
<html><head></head> <frameset rows="20%,*"> <frame src="title.html"> <frameset cols="30%,*"> <frame src="menu.html"> <frame src="content.html"> </frameset> </html>
frameset rows="#%, *"- rows defines the height that each frame will have. In the above example we chose the new title (the 1st row) to be 20% of the total page height and used a "*", which means that menu and content (which are the 2nd row) will use the remaining height.
You probably noticed those ugly gray lines that appear between the frames. It is possible to remove these and manipulate the spacing between frames with frameborder and framespacing. These attributes appear within the frameset tag. Note: Framespacing and border are the same attribute, but some browsers only recognize one or the other, so use both, with the same value, to be safe. frameborder="#" - A zero value shows no "window" border. border="#"- Modifies the border width, used by Netscape. framespacing="#" -Modifies the border width, used by Internet Explorer. Here's an example of the same frameset without the borders.
HTML Code:
<html><head></head> <frameset border="0" frameborder="0" framespacing="0" rows="20%,*"> <frame name="title" src="title.html"> <frameset border="0" frameborder="0" framespacing="0" cols="30%,*"> <frame src="menu.html"> <frame src="content.html"> </frameset> </html>
Frame Borders:
Here's a visual:Visual
HTML Code:
<html><head></head> <frameset border="2" frameborder="1" framespacing="2" rows="20%,*"> <frame src="title.html" noresize scrolling="no"> <frameset border="4" frameborder="1" framespacing="4" cols="30%,*"> <frame src="menu.html" scrolling="auto" noresize> <frame src="content.html" scrolling="yes" noresize> </frameset> </html>
HTML - Layout
Inner Table
<table id="shell" bgcolor="black" border="1" heigh="200" width="300"> <tr><td> <table id="inner" bgcolor="white" heigh="100" width="100"> <tr><td>Tables inside tables!</td></tr> </table> </td></tr></table>
HTML Code:
<!--Note to self: This is my banner image! Don't forget --> <img src="http://www.abc.com/pics/tizagSugar.jpg" height="100" width="200" />
Comment to self:
As you can see comment syntax may be a little complicated, there is an opening and a closing much like tags. <!-- Opening Comment -- > Closing Comment
HTML Code:
<input type="text" size="12" />
Input Field:
HTML - Body
As we mentioned, the body tag serves as the element containing all the content for the website. Tables, Lists, Forms, Paragraphs, everything must be placed within the body element to be displayed on your site.
HTML Code:
<body topmargin="50" leftmargin="50"> </body >
Text
<body text="red" > OR <body text="rgb(255,0,0)" >
HTML Code:
<body> <div style="background: green"> <h5 >SEARCH LINKS</h5> <a target="_blank" href="http://www.google.com">Google</a> </div> </body>
MARQUEE
It moves some text and also any image to any direction.
<MARQUEE WIDTH=100% BEHAVIOR=ALTERNATE BGColor=yellow DIRECTION=RIGHT >This is an example of an alternating marquee...</MARQUEE>