Learn HTML Basics - HTML DIV Tutorial  
Learn HTML Basics – Introduction and page one of Learn HTML Basics will dive right into the basics of HTML, and will teach you the meaning behind html and will try and give you a basic understanding of what it is, before we show you more of the basics of html.
   
Learn HTML - Page two of Learn HTML Basics will teach you how to enter markup, which is important when trying to learn html, because this is what helps format your documents.
   

HTML Basics - Page three of Learn HTML Basics will show you exactly how you can learn to create your own basic html web page.

   

Learning HTML - Page four of Learn HTML Basics aims to teach one of the more complicated portions when learning the basics of html, which is adding links.

   
Free HTML Tutorial – Is page five and the final page of Learn HTML Basics. Here you can view our closing of this article which teaches the basics of learning html, and where we recommend you can go for more advanced html tutorials.
   

HTML DIV Tutorial – Learning the basics of HTML

HTML Div Tutorial

HTML DIV TUTORIAL - INTRO

The definition of the HTML <div> tag is that it divides the HTML document into sections. The following tutorial will explain why the <div> tag is important and how it should be used. Proper usage of the <div> tag is fundamental to good HTML coding; the <div> tag is one of most powerful tools available to a Web developer.

The key to understanding the <div> tag is that it does not carry any semantic meaning. To give you a contrasting example, the <p> tag is used to specify paragraphs of text. As another example there is the <strong> tag, which is used to provide emphasis. Although both of those tags can be used to modify the layout of a HTML document, part of their purpose is to give meaning to different elements on the page. The <div> tag, and its cousin, the <span> tag, do not, on their own, give any meaning to their content. The usefulness of this quality will become apparent as you read on through this tutorial.

HTML DIV TUTORIAL - CSS

One of the most popular uses of <div> is to use it in combination with Cascading Style Sheets (CSS). CSS is a means of specifying the layout and style of different elements on the web-page. CSS can be used to specify just about any aspect of layout you could think of. Font size, font color, background color, borders, margins and text alignment are some of the things you can change with CSS.

The HTML <div> tag allows you to specify the areas of your document you wish to control with CSS. You may have four paragraphs that you want to center on the screen. What you might do is put them all within a pair of <div> tags and use CSS to make the content of those tags centered.

As the name suggests, use your <div> tags to divide your page up into different layout sections. Once you have done this, use CSS to specify the layout for those sections. Thus by combining the HTML <div> tag with CSS, you can build an unlimited variety of page layouts.

HTML DIV TUTORIAL - SEMANTICS

Another purpose of the <div> tag is to implement Web semantics. When people talk about Web semantics, or the semantic Web, they are talking about labelling the different elements of a web page so that a machine would be able to interpret the meaning behind them.

As mentioned in the beginning of this tutorial, the <p> tag can be used to signify a paragraph. So a machine reading a HTML page would know that the text inside the <p> tags represents a paragraph. What if you wanted to mark a more specific piece of information, like say a phone number? Unfortunately there is no <phone> tag, but this is where <div>, which has no prescribed semantic meaning, comes into play.

To explain, any <div> tag may carry an id or class attribute. Thus you might write, <div class="phone"> or <div id="mary_phone">. In this way, very specific semantic information can be embedded into your HTML document.

HTML DIV TUTORIAL - SCRIPTING

Another extremely important use for HTML <div> tags is to implement client-side scripting. Client-side scripting can be used to create animated buttons, scrolling text, drop down boxes, and many other engaging functionalities for your web-page. Typically when we talk about client-side scripting, we are talking about JavaScript.

Now, say you would like something interesting to happen when the user moves the mouse over a certain graphic on the page. You would like some piece of text to change depending on the graphic that the mouse has moved over. This is possible in JavaScript, but the JavaScript must be able to 'target' the piece of text somehow.

What can be done is the area where the text is to be changed can be contained within a <div> tag. The <div> tag is given an id, say, for example, <div id="text_target">. Now the JavaScript is will be able to take control of the text in that area of the page, by looking for a <div> tag with an id of "text_target".

So you see, proper <div> tag usage is essential for any JavaScript programmer.

DIV vs SPAN

Now, one last piece of information before I conclude this tutorial -- when to use a <span> tag and when to use a <div> tag.

What you should know is that <div> tags are block level elements that are used to divide up whole sections of HTML. The <span> tag, however, are in-line level elements, they only span across small amounts of content, typically words or phrases. For instance, a <span> tag might be used to make a word red in color, or to give it an underline. The crucial thing to remember is that a <span> tag can only contain other in-line elements, while a <div> tag can contain both in-line and block elements. Because of this, a <span> tag cannot contain images, tables or forms. However <span> is still used for the three purposes described above: to style with CSS, to give semantic meaning to web-page content, and to target web-page content with JavaScript. Practice all three of these purposes with both <div> and <span> and one day you will become a HTML master.

Thank you to Alex Hutton for this "HTML DIV Tutorial" article.

 

Latest HTML Tutorial Articles:

HTML Form Tutorial (NEW!) - An HTML form can allow people to enter data through a web page. This data can then be processed by their computer, or sent to the web-server and processed there. HTML forms can be used in many different ways. The most common use of a HTML form is to send a search query to a search engine, as with, for example, Google. This HTML form tutorial will give you all the information you need to start making your own HTML forms...

HTML DIV Tutorial - The definition of the HTML <div> tag is that it divides the HTML document into sections. The following tutorial will explain why the <div> tag is important and how it should be used. Proper usage of the <div> tag is fundamental to good HTML coding; the <div> tag is one of most powerful tools available to a Web developer...

HTML MySpace Tutorial - MySpace, one of the leading social networking websites on the internet, grows by leaps and bounds. For those that are new to the MySpace circle, there are several things that must be learned to enjoy all that it has to offer. HTML is a series of codes that are used to create website pages on MySpace, as well as change the features that are displayed. For a simple and easy to understand HTML MySpace tutorial, a MySpace account should first be created. This can be done by signing up for a free account on the website. Once an account is established and the user is logged in, the HTML changes can come into play. With MySpace there are numerous HTML codes that are used for such features as leaving comments, changing pictures, and uploading graphics for backgrounds...

HTML Frame Tutorial - The use of frames may not be as prevalent in HTML design as it once was, but it is still a worthy form of organizing your Web site and making it easy to navigate. Dividing a page using frames (called a frameset) allows the visitor to view more than one page at a time without cluttering the screen. Each frame is its own Web site and can be viewed independently in a separate window. The use of frames can be a dynamic way to get the most visual aspect out of your Web site. For example, the banner frame can be used for a business logo along with the company name. The index frame, on the left side of the screen, can be used as a table of contents, or as a place to link to other Web sites. The home frame will contain all the primary contents of the site, whose data changes each time the visitor clicks on a link. The footer frame...

HTML Table Tutorial - If you are embarking on a project to start your own Web site, you should know that the use of HTML tables will make your business or personal venture thrive. Reference any professionally produced Web site and you will find that the most successful sites use many HTML tables to draw the browser’s attention. It is identical to using colorful graphics and charts as part of a report to highlight the nuts and bolts of your presentation. Most Web sites utilize invisible HTML tables to divide the page into different sections. HTML tables can be used to create headers, menus and forms. They are also valuable for text and alignment of photos to create an organized display...

   
   
     
Copyright Learnhtmlbasics.com © 2006-2008, All rights reserved