This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Monday, 20 February 2012

css and html code for an html form

HTML Forms

HTML forms are used to pass data to a web server or mail server.






























Code below produces the above out put. Click here for going to detail page

<head>
<style type="text/css">
/* ----------- stylized ----------- */
label
{
width: 9em;
float: left;
text-align: right;
margin-right: 0.5em;
display: block
}
.submit
{
margin-left: 11.5em;
}
input
{
color: #781351;
background: #fee3ad;
border: 1px solid #781351;
}
textarea{
color: #781351;
background: #fee3ad;
border: 1px solid #781351
}
select {
color: #781351;
background: #fee3ad;
border: 1px solid #781351;
margin-right: 2px
}
.submit input
{
color: #000;
background: #ffa20f;
border: 2px outset #d7b9c9
}
fieldset
{
border: 1px solid #781351;
width: 30em;
margin:0 auto;
}
legend
{
color: #fff;
background: #ffa20c;
border: 1px solid #781351;
padding: 2px 6px
}
</style>
</head>


<body>

<fieldset>
<legend>This is my form</legend>
<form action="" method="post" name="first_form" enctype="multipart/form-data" onsubmit="validation()">
<p><label for="email">Email:</label><input type="text" name="email" maxlength="50"  value="" class="input"/></p>
<p><label for="password" >Password:</label><input type="password" name="password" class="input"/></p>
<p><label for="confirm_password" >Confirm Password:</label><input type="password" name="confirm_password" class="input"/></p>
<p><label for="file">Upload Your Picture:</label><input type="file" name="userfile" class="input" /></p>
<input type="hidden" name="actionflag" value="save" />
<input type="hidden" name="chech_file_size" value="5000"/>
<p><label for="gender">Gender:</label><input type="radio" name="gender" value="male" />Male<input type="radio" name="gender" value="female" class="input" />Female<br /></p>
<p><label for="country">Select Country:</label><select name="country">
<option value="UK">United Kingdom</option>
<option value="USA">United States of America</option>
<option value="SA">south Africa </option>
</select></p>
<p><label for="hobby">Hobby:</label><input type="checkbox" name="cricket" value="cricket" />Cricket<input type="checkbox" name="football" value="football" />Football</p>
<p><label for="address">Address</label><textarea rows="6" cols="25" name="address"></textarea></p>
<p><input type="submit" value="Submit" class="submit"/></p>
</form>
</fieldset>
</body>
</html>

Thursday, 16 February 2012

How to make an html form with fieldset tag



HTML Forms

HTML forms are used to pass data to a web server or mail server. We may want to give the form its own title and border. To do this we use the <fieldset> and <legend> tags to the HTML code: e.g. copy and past below code and see what it do for you.
<fieldset>
<legend>This is my form</legend>
      form code will go here.
</fieldset>

The HTML form tag

All the input elements should be enclosed within the opening and closing form tags this is form starting tag:
<form action="" method="post" name="first_form" enctype="multipart/form-data" onsubmit="validation()">

action='save.php'
The action attribute points to the server side script (‘back end’) that handles the form submission. Usually, this will be a script (PHP,ASP, Perl) or a CGI program. In other words the action is used to indicate the file name through which data is passed to the server. If you want to send data to a mail server you can write your email address after equal sign of action like this action=”your_email@yahoo.com” etc.
method ='get' or method = 'post'
If you use GET method, the form submission values are passed as part of the URL. If it is POST, the information is sent to the server as part of the data body and will not be visible in the address bar in the user’s browser. If you don’t specify the method, GET is taken by default.
name =”firstForm”
Form name is used for java script validation etc. you can see the java script validation of complete signup form here javascriptvalidation@yahoo.com.
enctype="multipart/form-data"
While creating a form with file upload support, do remember to add an attribute enctype=“multipart/form-data” in your
tag.

The form input elements

You can use different types of input elements in a form. Examples are: check boxes, radio buttons, text fields etc.

Text field

text field is used to collect the name, email, phone number etc from your web site visitors. Here is the code to create a simple text box:
<label for="email">Email:</label><input type="text" name="email" maxlength="50" value="" class="input"/>
label
Allows authors to assign a shorter label for the element, to be shown instead of the element's content as Email in above text field code example.
type=”text”
The ‘type’ attribute tells the browser that a single line text input box should be created.
name=”email”
Give a name to the field. The name is used to identify the field on the server side.
nvalue=””
The text you give as value will be displayed by default in the text box and this value will be pass to the server.
nvalue=””
The text you give as value will be displayed by default in the text box and this value will be pass to the server.
maxlength=”60”
Specifies the maximum number of characters the user can enter into this text box. Note that the default width of a text field is 50 characters.
class=”input”
class can have any name “input” is in this case, class name is used for css and java script you can see css of this form here cssoffrom@yahoo.com.

Password Text field

You can create a password field by using the input type =‘password’ e.g.
<label for="password" >Password:</label><input type="password" name="password" value=”123”/>
Note: The characters in a password field are masked (shown as asterisks or circles)

File Upload field

Use this field if you want to give an option to user for uploading file or picture.
<label for="file">Upload Your Picture:</label><input type="file" name="userfile" />
Note: Allowing users to upload files is a big security risk. Only permit trusted users to perform file uploads. See here how to upload a file to server. www.b2atutorials.com.

Hidden Text field

<input type="hidden" name="chech_file_size" value="5000"/>
The input type=‘hidden’ is not shown to the user. Usually developer uses this for security purpose etc. For example I will check if file uploaded from <input type=”file" > is greater than value of hidden text field (e.g. from value=”5000” which is equal to 5 KB) then file should not be uploaded.

Radio button

<label for="gender">Gender:</label>
<input type="radio" name="gender" value="male" />Male
<input type="radio" name="gender" value="female" />Female
Radio buttons are used for selecting one item from a set of choices. Use radio buttons when the choices are not too large. Each individual button need to be created using input type ‘radio’.
name=”gender”
Name of each individual radio button will be same for one set of choices as name=” gender” is in above case for both buttons.
value=””
if user checked the Male value= “male” will pass to server or if user checked the Female value=”female” will be passed to server other wise value=””.
checked=”checked”
Having the ‘checked’ attribute makes the check box ‘on’ by default.

Chech boxes

<label for="hobby">Hobby:</label>
<input type="checkbox" name="cricket" value="cricket" />Cricket
<input type="checkbox" name="football" value="football" />Football
Chech boxes are used for selecting one or many from a set of choices. like radio button each individual box need to be created using input type ‘chechbox’.
name=”cricket” and name=”football”
Name of each individual chechbox will be different for one set of choices as name=” cricket” for first box and name=”football” for second box in above case. It is difficult to handle different name of checkboxes for getting values. So easy way of getting checkboxes values is use of array like name=”hobby[]” for above example. How to get values of check boxes in php? Answer of this question is here www.b2atutorials.com.
value=”cricket” and value=”football”
If user checked first box value=”cricket” will be sent to server. If user checked nothing value=”” will be passed to server. If user checked all boxes all values should be passed to server.

Drop down list

<label for="country">Select Country:</label>
<select name="country">
<option value="UK">United Kingdom</option>
<option value="USA">United States of America</option>
<option value="SA">South Africa </option>
</select>
When you want to create a list of items for the user to select one value from form, create a drop down list. Instead of using input tag use <select> tag for creating a drop down list and give it a proper name as name=”country” in above example. Then use option tag for defining an option in a list. The option element goes inside the select element.
value=”UK”
value of selected option will be pass to server.
selected=”selected”
Use selected='selected' if you want a particular option should be selected when user come to the form. Like bellow
<option value=”SA” selected=”selected”> South Africa</option>

select multiple

<select multiple name="country">
If you will use multiple in select tag user will be able to select multiple countries form the above drop down list. Remember that handle getting multiple values as you see in check boxes (by using array like name=”country[]”) however it is more user-friendly to use checkboxes instead.

Text area

When you want to get a bunch of text from the user, the Textarea can be used. A TextArea is created using the tag <textarea>.
<label for="address">Address</label><textarea rows="6" cols="25" name="address"></textarea>
name=”address”
The name identifies this TextArea in the server side script.
cols=”25”
Defines the width (number of characters per line) the text area can accommodate without scrolling.
rows=”5”
Defines the number of lines (number of rows) the text area can accommodate without scrolling.

General button

A button input just displays a button on the form. To add meaning to the button, we need to add JavaScript code to handle the event when the user presses the button.
<input type="button" value="Click" onclick="alert('clicked')">
This code displays a button with label “Click!”. On pressing the button, a message box with message ‘Clicked’ is displayed.

Reset button

<input type="reset" value="Reset"/>
When the user presses the Reset button, all the elements in the form are reset to their default values./p>

Submit button

After entering the data, the user presses the submit button which triggers the browser to send the data to the server. You can add a submit button to the form using input=‘submit’.
<input type="submit" value="Submit" class="submit"/>
name =”submit”
There can be more than one submit buttons in a form. On the server side, the submit button which was pressed can be identified using the ‘name’ attribute.
value=”Submit”
The string given in the ‘value’ attribute is displayed as the label of the Submit button.

Saturday, 28 January 2012

Linking



The chief power of HTML comes from its ability to link text and/or an image to another document or section of a document. A browser highlights the identified text or image with color and/or underlines to indicate that it is a hypertext link (often shortened to hyperlink or just link).

HTML's single hypertext-related tag is <A>, which stands for anchor. To include an anchor in your document:

start the anchor with <A (include a space after the A)
specify the document you're linking to by entering the parameter HREF="filename" followed by a closing right angle bracket (>)
enter the text that will serve as the hypertext link in the current document
enter the ending anchor tag: </A> (no space is needed before the end anchor tag)

Here is a sample hypertext reference in a file called US.html:

    <A HREF="MaineStats.html">Maine</A>

This entry makes the word Maine the hyperlink to the document MaineStats.html, which is in the same directory as the first document.

Relative Pathnames Versus Absolute Pathnames

You can link to documents in other directories by specifying the relative path from the current document to the linked document. For example, a link to a file NYStats.html located in the subdirectory AtlanticStates would be:

    <A HREF="AtlanticStates/NYStats.html">New York</A>

These are called relative links because you are specifying the path to the linked file relative to the location of the current file. You can also use the absolute pathname (the complete URL) of the file, but relative links are more efficient in accessing a server. They also have the advantage of making your documents more "portable" -- for instance, you can create several web pages in a single folder on your local computer, using relative links to hyperlink one page to another, and then upload the entire folder of web pages to your web server. The pages on the server will then link to other pages on the server, and the copies on your hard drive will still point to the other pages stored there.

It is important to point out that UNIX is a case-sensitive operating system where filenames are concerned, while DOS and the MacOS are not. For instance, on a Macintosh, "DOCUMENT.HTML", "Document.HTML", and "document.html" are all the same name. If you make a relative hyperlink to "DOCUMENT.HTML", and the file is actually named "document.html", the link will still be valid. But if you upload all your pages to a UNIX web server, the link will no longer work. Be sure to check your filenames before uploading.

Pathnames use the standard UNIX syntax. The UNIX syntax for the parent directory (the directory that contains the current directory) is "..". (For more information consult a beginning UNIX reference text such as Learning the UNIX Operating System from O'Reilly and Associates, Inc.)

If you were in the NYStats.html file and were referring to the original document US.html, your link would look like this:

    <A HREF="../US.html">United States</A>

In general, you should use relative links whenever possible because:
it's easier to move a group of documents to another location (because the relative path names will still be valid)
it's more efficient connecting to the server
there is less to type

However, use absolute pathnames when linking to documents that are not directly related. For example, consider a group of documents that comprise a user manual. Links within this group should be relative links. Links to other documents (perhaps a reference to related software) should use absolute pathnames instead. This way if you move the user manual to a different directory, none of the links would have to be updated.

URLs

The World Wide Web uses Uniform Resource Locators (URLs) to specify the location of files on other servers. A URL includes the type of resource being accessed (e.g., Web, gopher, FTP), the address of the server, and the location of the file. The syntax is:

scheme://host.domain [:port]/path/ filename

where scheme is one of
file
a file on your local system
ftp
a file on an anonymous FTP server
http
a file on a World Wide Web server
gopher
a file on a Gopher server
WAIS
a file on a WAIS server
news
a Usenet newsgroup
telnet
a connection to a Telnet-based service

The port number can generally be omitted. (That means unless someone tells you otherwise, leave it out.)

For example, to include a link to this primer in your document, enter:

<A HREF="http://www.ncsa.uiuc.edu/General/Internet/WWW/HTMLPrimer.html">
NCSA's Beginner's Guide to HTML</A>

This entry makes the text NCSA's Beginner's Guide to HTML a hyperlink to this document.

There is also a mailto scheme, used to hyperlink email addresses, but this scheme is unique in that it uses only a colon (:) instead of :// between the scheme and the address. You can read more about mailto below.

For more information on URLs, refer to:

WWW Names and Addresses, URIs, URLs, URNs
A Beginner's Guide to URLs
Links to Specific Sections

Anchors can also be used to move a reader to a particular section in a document (either the same or a different document) rather than to the top, which is the default. This type of an anchor is commonly called a named anchor because to create the links, you insert HTML names within the document.

This guide is a good example of using named anchors in one document. The guide is constructed as one document to make printing easier. But as one (long) document, it can be time-consuming to move through when all you really want to know about is one bit of information about HTML. Internal hyperlinks are used to create a "table of contents" at the top of this document. These hyperlinks move you from one location in the document to another location in the same document. (Go to the top of this document and then click on the Links to Specific Sections hyperlink in the table of contents. You will wind up back here.)

You can also link to a specific section in another document. That information is presented first because understanding that helps you understand linking within one document.

Links Between Sections of Different Documents

Suppose you want to set a link from document A (documentA.html) to a specific section in another document (MaineStats.html).

Enter the HTML coding for a link to a named anchor:

     documentA.html:   
     In addition to the many state parks, Maine is also home to
     <a href="MaineStats.html#ANP">Acadia National Park</a>.

Think of the characters after the hash (#) mark as a tab within the MaineStats.html file. This tab tells your browser what should be displayed at the top of the window when the link is activated. In other words, the first line in your browser window should be the Acadia National Park heading.

Next, create the named anchor (in this example "ANP") in MaineStats.html:

  <H2><A NAME="ANP">Acadia National Park</a></H2>

With both of these elements in place, you can bring a reader directly to the Acadia reference in MaineStats.html.

NOTE: You cannot make links to specific sections within a different document unless either you have write permission to the coded source of that document or that document already contains in-document named anchors. For example, you could include named anchors to this primer in a document you are writing because there are named anchors in this guide (use View Source in your browser to see the coding). But if this document did not have named anchors, you could not make a link to a specific section because you cannot edit the original file on NCSA's server.

Links to Specific Sections within the Current Document

The technique is the same except the filename is omitted.

For example, to link to the ANP anchor from within MaineStats, enter:

  ...More information about
  <A HREF="#ANP">Acadia National Park</a>
  is available elsewhere in this document.
   
Be sure to include the <A NAME=> tag at the place in your document where you want the link to jump to (<A NAME="ANP">Acadia National Park</a>).

Named anchors are particularly useful when you think readers will print a document in its entirety or when you have a lot of short information you want to place online in one file.

Mailto

You can make it easy for a reader to send electronic mail to a specific person or mail alias by including the mailto attribute in a hyperlink. The format is:

<A HREF="mailto:emailinfo@host">Name</a>

For example, enter:
 <A HREF="mailto:pubs@ncsa.uiuc.edu">
 NCSA Publications Group</a>

to create a mail window that is already configured to open a mail window for the NCSA Publications Group alias. (You, of course, will enter another mail address!)

Character Formatting


HTML has two types of styles for individual words or sentences: logical and physical. Logical styles tag text according to its meaning, while physical styles indicate the specific appearance of a section. For example, in the preceding sentence, the words "logical styles" was tagged as "emphasis." The same effect (formatting those words in italics) could have been achieved via a different tag that tells your browser to "put these words in italics."

Logical Versus Physical Styles

If physical and logical styles produce the same result on the screen, why are there both?

In the ideal SGML universe, content is divorced from presentation. Thus SGML tags a level-one heading as a level-one heading, but does not specify that the level-one heading should be, for instance, 24-point bold Times centered. The advantage of this approach (it's similar in concept to style sheets in many word processors) is that if you decide to change level-one headings to be 20-point left-justified Helvetica, all you have to do is change the definition of the level-one heading in your Web browser. Indeed, many browsers today let you define how you want the various HTML tags rendered on-screen using what are called cascading style sheets, or CSS. CSS is more advanced than HTML, though, and will not be covered in this Primer. (You can learn more about CSS at the World Wide Web Consortium CSS site.)

Another advantage of logical tags is that they help enforce consistency in your documents. It's easier to tag something as <H1> than to remember that level-one headings are 24-point bold Times centered or whatever. For example, consider the <STRONG> tag. Most browsers render it in bold text. However, it is possible that a reader would prefer that these sections be displayed in red instead. (This is possible using a local cascading style sheet on the reader's own computer.) Logical styles offer this flexibility.

Of course, if you want something to be displayed in italics (for example) and do not want a browser's setting to display it differently, you should use physical styles. Physical styles, therefore, offer consistency in that something you tag a certain way will always be displayed that way for readers of your document.

Try to be consistent about which type of style you use. If you tag with physical styles, do so throughout a document. If you use logical styles, stick with them within a document. Keep in mind that future releases of HTML might not support certain logical styles, which could mean that browsers will not display your logical-style coding. (For example, the <DFN> tag -- short for "definition", and typically displayed in italics -- is not widely supported and will be ignored if the reader's browser does not understand it.)

Logical Styles


<DFN>
for a word being defined. Typically displayed in italics. (NCSA Mosaic is a World Wide Web browser.)
<EM>
for emphasis. Typically displayed in italics. (Consultants cannot reset your password unless you call the help line.)
<CITE>
for titles of books, films, etc. Typically displayed in italics. (A Beginner's Guide to HTML)
<CODE>
for computer code. Displayed in a fixed-width font. (The <stdio.h> header file)
<KBD>
for user keyboard entry. Typically displayed in plain fixed-width font. (Enter passwd to change your password.)
<SAMP>
for a sequence of literal characters. Displayed in a fixed-width font. (Segmentation fault: Core dumped.)
<STRONG>
for strong emphasis. Typically displayed in bold. (NOTE: Always check your links.)
<VAR>
for a variable, where you will replace the variable with specific information. Typically displayed in italics. (rm filename deletes the file.)

Physical Styles


<B>
bold text
<I>
italic text
<TT>
typewriter text, e.g. fixed-width font.
Escape Sequences (a.k.a. Character Entities)

Character entities have two functions:

escaping special characters displaying other characters not available in the plain ASCII character set (primarily characters with diacritical marks)
Three ASCII characters--the left angle bracket (<), the right angle bracket (>), and the ampersand (&)--have special meanings in HTML and therefore cannot be used "as is" in text. (The angle brackets are used to indicate the beginning and end of HTML tags, and the ampersand is used to indicate the beginning of an escape sequence.) Double quote marks may be used as-is but a character entity may also be used (").

To use one of the three characters in an HTML document, you must enter its escape sequence instead:

&lt;
the escape sequence for <
&gt;
the escape sequence for >
&amp;
the escape sequence for &

Additional escape sequences support accented characters, such as:

&ouml;
a lowercase o with an umlaut: ö
&ntilde;
a lowercase n with a tilde: ñ
&Egrave;
an uppercase E with a grave accent: È
You can substitute other letters for the o, n, and E shown above. Visit the World Wide Web Consortium for a complete list of special characters.

NOTE: Unlike the rest of HTML, the escape sequences are case sensitive. You cannot, for instance, use &LT; instead of &lt;.

Markup Tags


Markup Tags

HTML
This element tells your browser that the file contains HTML-coded information. The file extension .html also indicates this an HTML document and must be used. (If you are restricted to 8.3 filenames (e.g., LeeHome.htm, use only .htm for your extension.)

HEAD
The head element identifies the first part of your HTML-coded document that contains the title. The title is shown as part of your browser's window (see below).

TITLE
The title element contains your document title and identifies its content in a global context. The title is typically displayed in the title bar at the top of the browser window, but not inside the window itself. The title is also what is displayed on someone's hotlist or bookmark list, so choose something descriptive, unique, and relatively short. A title is also used to identify your page for search engines (such as HotBot or Infoseek).

For example, you might include a shortened title of a book along with the chapter contents: NCSA Mosaic Guide (Windows): Installation. This tells the software name, the platform, and the chapter contents, which is more useful than simply calling the document Installation. Generally you should keep your titles to 64 characters or fewer.

BODY
The second--and largest--part of your HTML document is the body, which contains the content of your document (displayed within the text area of your browser window). The tags explained below are used within the body of your HTML document.

Headings
HTML has six levels of headings, numbered 1 through 6, with 1 being the largest. Headings are typically displayed in larger and/or bolder fonts than normal body text. The first heading in each document should be tagged <H1>.

The syntax of the heading element is:
<Hy>Text of heading </Hy>
where y is a number between 1 and 6 specifying the level of the heading.
Do not skip levels of headings in your document. For example, don't start with a level-one heading (<H1>) and then next use a level-three (<H3>) heading.

Paragraphs
Unlike documents in most word processors, carriage returns in HTML files aren't significant. In fact, any amount of whitespace -- including spaces, linefeeds, and carriage returns -- are automatically compressed into a single space when your HTML document is displayed in a browser. So you don't have to worry about how long your lines of text are. Word wrapping can occur at any point in your source file without affecting how the page will be displayed.

In the bare-bones example shown in the Minimal HTML Document section, the first paragraph is coded as

    <P>Welcome to the world of HTML.
    This is the first paragraph.
    While short it is
    still a paragraph!</P>


In the source file there is a line break between the sentences. A Web browser ignores this line break and starts a new paragraph only when it encounters another <P> tag.
Important: You must indicate paragraphs with <P> elements. A browser ignores any indentations or blank lines in the source text. Without <P> elements, the document becomes one large paragraph. (One exception is text tagged as "preformatted," which is explained below.) For example, the following would produce identical output as the first bare-bones HTML example:

    <H1>Level-one heading</H1>
    <P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph! </P>  
<P>And this is the second paragraph.</P>

To preserve readability in HTML files, put headings on separate lines, use a blank line or two where it helps identify the start of a new section, and separate paragraphs with blank lines (in addition to the <P> tags). These extra spaces will help you when you edit your files (but your browser will ignore the extra spaces because it has its own set of rules on spacing that do not depend on the spaces you put in your source file).

NOTE: The </P> closing tag may be omitted. This is because browsers understand that when they encounter a <P> tag, it means that the previous paragraph has ended. However, since HTML now allows certain attributes to be assigned to the <P> tag, it's generally a good idea to include it.

Using the <P> and </P> as a paragraph container means that you can center a paragraph by including the ALIGN=alignment attribute in your source file.

    <TT><P ALIGN=CENTER></TT>
    This is a centered paragraph.
    [See the formatted version below.]
    </P>
This is a centered paragraph.

It is also possible to align a paragraph to the right instead, by including the ALIGN=RIGHT attribute. ALIGN=LEFT is the default alignment; if no ALIGN attribute is included, the paragraph will be left-aligned.

Lists
HTML supports unnumbered, numbered, and definition lists. You can nest lists too, but use this feature sparingly because too many nested items can get difficult to follow.

Unnumbered Lists
To make an unnumbered, bulleted list, start with an opening list <UL> (for unnumbered list) tag
enter the <LI> (list item) tag followed by the individual item; no closing </LI> tag is needed
end the entire list with a closing list </UL> tag

Below is a sample three-item list:
    <UL>
    <LI> apples
    <LI> bananas
    <LI> grapefruit
    </UL>
The output is:
       apples
       bananas
       grapefruit
The <LI> items can contain multiple paragraphs. Indicate the paragraphs with the <P> paragraph tags.

Numbered Lists 


A numbered list (also called an ordered list, from which the tag name derives) is identical to an unnumbered list, except it uses <OL> instead of <UL>. The items are tagged using the same <LI> tag. The following HTML code:

    <OL>
    <LI> oranges
    <LI> peaches
    <LI> grapes
    </OL>

produces this formatted output:
    1. oranges
    2. peaches
    3. grapes

Definition Lists 

A definition list (coded as <DL>) usually consists of alternating a definition term (coded as <DT>) and a definition definition (coded as <DD>). Web browsers generally format the definition on a new line and indent it.

The following is an example of a definition list:

    <DL>
    <DT> NCSA
    <DD> NCSA, the National Center for Supercomputing
      Applications, is located on the campus of the
      University of Illinois at Urbana-Champaign.
    <DT> Cornell Theory Center
    <DD> CTC is located on the campus of Cornell
      University in Ithaca, New York.
    </DL>


The output looks like:

NCSA
NCSA, the National Center for Supercomputing Applications, is located on the campus of the University of Illinois at Urbana-Champaign.
Cornell Theory Center
CTC is located on the campus of Cornell University in Ithaca, New York.

The <DT> and <DD> entries can contain multiple paragraphs (indicated by <P> paragraph tags), lists, or other definition information.

The COMPACT attribute can be used routinely in case your definition terms are very short. If, for example, you are showing some computer options, the options may fit on the same line as the start of the definition.

<DL COMPACT>
<DT> -i
<DD>invokes NCSA Mosaic for Microsoft Windows
  using the initialization file defined in the path
<DT> -k
<DD>invokes NCSA Mosaic for Microsoft Windows in
  kiosk mode
</DL>

The output looks like:
-i
invokes NCSA Mosaic for Microsoft Windows using the initialization file defined in the path.
-k
invokes NCSA Mosaic for Microsoft Windows in kiosk mode.

Nested Lists 

Lists can be nested. You can also have a number of paragraphs, each containing a nested list, in a single list item.

Here is a sample nested list:

    <UL>
    <LI> A few New England states:
        <UL>
        <LI> Vermont
        <LI> New Hampshire
        <LI> Maine
        </UL>
    <LI> Two Midwestern states:
        <UL>
        <LI> Michigan
        <LI> Indiana
        </UL>
    </UL>

The nested list is displayed as

A few New England states:
        Vermont
        New Hampshire
        Maine
Two Midwestern states:
        Michigan
        Indiana
        Preformatted Text

Use the<PRE> tag (which stands for "preformatted") to generate text in a fixed-width font. This tag also makes spaces, new lines, and tabs significant -- multiple spaces are displayed as multiple spaces, and lines break in the same locations as in the source HTML file. This is useful for program listings, among other things. For example, the following lines:

    <PRE>
      #!/bin/csh
      cd $SCR
      cfs get mysrc.f:mycfsdir/mysrc.f
      cfs get myinfile:mycfsdir/myinfile  
      fc -02 -o mya.out mysrc.f  
      mya.out
      cfs save myoutfile:mycfsdir/myoutfile
      rm *
    </PRE>


display as:

      #!/bin/csh
      cd $SCR
      cfs get mysrc.f:mycfsdir/mysrc.f
      cfs get myinfile:mycfsdir/myinfile  
      fc -02 -o mya.out mysrc.f  
      mya.out
      cfs save myoutfile:mycfsdir/myoutfile
      rm *


The <PRE> tag can be used with an optional WIDTH attribute that specifies the maximum number of characters for a line. WIDTH also signals your browser to choose an appropriate font and indentation for the text.

Hyperlinks can be used within <PRE> sections. You should avoid using other HTML tags within <PRE> sections, however.

Note that because <, >, and & have special meanings in HTML, you must use their escape sequences (&lt;, &gt;, and &amp;, respectively) to enter these characters. See the section Escape Sequences for more information.

Extended Quotations

Use the <BLOCKQUOTE> tag to include lengthy quotations in a separate block on the screen. Most browsers generally change the margins for the quotation to separate it from surrounding text.

In the example:
    <P>Omit needless words.</P>
    <BLOCKQUOTE>
    <P>Vigorous writing is concise. A sentence should
    contain no unnecessary words, a paragraph no unnecessary
    sentences, for the same reason that a drawing should have
    no unnecessary lines and a machine no unnecessary parts.
    </P>
    <P>--William Strunk, Jr., 1918 </P>
    </BLOCKQUOTE>

the result is:

Omit needless words.

Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts.

--William Strunk, Jr., 1918

Forced Line Breaks/Postal Addresses

The <BR> tag forces a line break with no extra (white) space between lines. Using <P> elements for short lines of text such as postal addresses results in unwanted additional white space. For example, with

    National Center for Supercomputing Applications<BR>
    605 East Springfield Avenue<BR>
    Champaign, Illinois 61820-5518<BR>

The output is:

National Center for Supercomputing Applications
605 East Springfield Avenue
Champaign, Illinois 61820-5518

Horizontal Rules

The <HR> tag produces a horizontal line the width of the browser window. A horizontal rule is useful to separate major sections of your document.

You can vary a rule's size (thickness) and width (the percentage of the window covered by the rule). Experiment with the settings until you are satisfied with the presentation. For example:

<HR SIZE=4 WIDTH="50%">

displays as:
___________________________________________________

What an HTML Document Is?

HTML documents are plain-text (also known as ASCII) files that can be created using any text editor (e.g., Emacs or vi on UNIX machines; SimpleText on a Macintosh; Notepad on a Windows machine). You can also use word-processing software if you remember to save your document as "text only with line breaks". 

HTML Editors

Some WYSIWYG editors are also available (e.g., Claris Home Page or Adobe PageMill, both for Windows and Macintosh). You may wish to try one of them after you learn some of the basics of HTML tagging. WYSIWYG is an acronym for "what you see is what you get"; it means that you design your HTML document visually, as if you were using a word processor, instead of writing the markup tags in a plain-text file and imagining what the resulting page will look like. It is useful to know enough HTML to code a document before you determine the usefulness of a WYSIWYG editor, in case you want to add HTML features that your editor doesn't support. 

If you haven't already selected your software, refer to Tom Magliery's online listing of HTML editors (organized by platform) to help you in your search for appropriate software. 

Getting Your Files on a Server

If you have access to a Web server at school or work, contact your webmaster (the individual who maintains the server) to see how you can get your files on the Web. If you do not have access to a server at work or school, check to see if your community operates a FreeNet, a community-based network that provides free access to the Internet. Lacking a FreeNet, you may need to contact a local Internet provider that will post your files on a server for a fee. (Check your local newspaper for advertisements or with your Chamber of Commerce for the names of companies.) 

Tags Explained

An element is a fundamental component of the structure of a text document. Some examples of elements are heads, tables, paragraphs, and lists. Think of it this way: you use HTML tags to mark the elements of a file for your browser. Elements can contain plain text, other elements, or both. 

To denote the various elements in an HTML document, you use tags. HTML tags consist of a left angle bracket (<), a tag name, and a right angle bracket (>). Tags are usually paired (e.g., <H1> and </H1>) to start and end the tag instruction. The end tag looks just like the start tag except a slash (/) precedes the text within the brackets. HTML tags are listed below. 

Some elements may include an attribute, which is additional information that is included inside the start tag. For example, you can specify the alignment of images (top, middle, or bottom) by including the appropriate attribute with the image source HTML code. Tags that have optional attributes are noted below. 

NOTE: HTML is not case sensitive. <title> is equivalent to <TITLE> or <TiTlE>. There are a few exceptions noted in Escape Sequences below. 

Not all tags are supported by all World Wide Web browsers. If a browser does not support a tag, it will simply ignore it. Any text placed between a pair of unknown tags will still be displayed, however. 

The Minimal HTML Document

Every HTML document should contain certain standard HTML tags. Each document consists of head and body text. The head contains the title, and the body contains the actual text that is made up of paragraphs, lists, and other elements. Browsers expect specific information because they are programmed according to HTML and SGML specifications. 

Required elements are shown in this sample bare-bones document: 


    <html>
    <head>
    <TITLE>A Simple HTML Example</TITLE>
    </head>
    <body>
    <H1>HTML is Easy To Learn</H1>
    <P>Welcome to the world of HTML.
    This is the first paragraph. While short it is  
    still a paragraph!</P>
    <P>And this is the second paragraph.</P>
    </body>
    </html>

The required elements are the <html>, <head>, <title>, and <body> tags (and their corresponding end tags). Because you should include these tags in each file, you might want to create a template file with them. (Some browsers will format your HTML file correctly even if these tags are not included. But some browsers won't! So make sure to include them.) 

Click to see the formatted version of the example. A longer example is also available but you should read through the rest of the guide before you take a look. This longer-example file contains tags explained in the next section. 


A Teaching Tool

To see a copy of the file that your browser reads to generate the information in your current window, select View Source (or the equivalent) from the browser menu. (Most browsers have a "View" menu under which this command is listed.) The file contents, with all the HTML tags, are displayed in a new window. 

This is an excellent way to see how HTML is used and to learn tips and constructs. Of course, the HTML might not be technically correct. Once you become familiar with HTML and check the many online and hard-copy references on the subject, you will learn to distinguish between "good" and "bad" HTML. 

Remember that you can save a source file with the HTML codes and use it as a template for one of your Web pages or modify the format to suit your purposes. 

Thursday, 26 January 2012

Getting Started to HTML

Terms to Know

WWW
           World Wide Web
Web
         World Wide Web
SGML
         Standard Generalized Markup Language--a standard for describing markup languages
DTD
        Document Type Definition--this is the formal specification of a markup language, written using SGML
HTML
        HyperText Markup Language--HTML is an SGML DTD

In practical terms, HTML is a collection of platform-independent styles (indicated by markup tags) that define the various components of a World Wide Web document. HTML was invented by Tim Berners-Lee while at CERN, the European Laboratory for Particle Physics in Geneva.
What Isn't Covered
       This primer assumes that you: know how to use NCSA Mosaic or some other Web browser
have a general understanding of how Web servers and client browsers work
have access to a Web server (or that you want to produce HTML documents for personal use in local-viewing mode)

HTML Version
     This guide reflects the most current specification--HTML Version 4.0-- plus some additional features that have been widely and consistently implemented in browsers. Future versions and new features for HTML are under development.