SIGN UP MEMBER LOGIN:    
ARTICLE

Introduction to Page Layout using DIV element

Posted by Sateesh Arveti Articles | ASP.NET Programming February 03, 2009
This article explains about benefits of using DIV tag over TABLE in page layout design.
Reader Level:


We normally use either TABLE or DIV tag to create page layout like specifying control's position, splitting the page etc. But, most of the developers prefer using TABLE instead of DIV tag. In this article, I am going to discuss about the advantages of using DIV instead of TABLE tag with an example. I am using VS 2008 for this sample. Around 70 - 80% sites are using TABLE element for creating page layouts.
But, DIV element gives following benefits, when compared to TABLE:

  1. Fewer Markups: By using DIV tag, markup code needed to create page layout is less than using TABLE tag.
  2. Low Bandwidth Loading: By using DIV tag, markup will be less which in turn loads page quickly on low bandwidth networks.
  3. Low Browser Burden: Since, Markup will be less by using DIV tag. The load and time needed by the browser for page display will be low.
  4. Easy to Change Layout: By using DIV tag, we can easily modify our page layout. Since, we can manage the layout using DIVs and design using style sheets separately and easily.
  5. Multiple Resolutions: By using DIV tag, we can make sure our page works at different screen resolutions and widths.
  6. Absolute Positioning: By using DIV tag, we can position the controls absolutely on a page.
  7. High Priority: DIV tags will be loaded first on a page, when compared to a table tag. Because of this, contents present in the DIV tag will be displayed first before the complete page loads.

Let's see the above benefits in a sample. Open your VS 2008 and create a new Website and name it as DIVLayoutSample.
Create a layout to your default page using TABLE tag with a header, footer, left, right and content in the center of the page as shown below in between form tag:
image1.gif
Run the application, the output will be like this:
image2.gif
Now, we will implement the same layout using DIV tags. Remove above markup and add this DIV markup as shown below:
image3.gif
Firstly, lot of markup got reduced. Secondly, it's easy to add/modify existing page layout. Page will also get loaded very fast, because of fewer markups and less load on browser for loading the page. It works very well on low bandwidth networks.
We can still reduce the code by replacing the position, top and left attributes with float attribute as shown below:
image4.gif
float attribute makes a DIV to float left/right direction. clear attribute clears previously specified float attributes. By using stylesheets, we can split HTML markup (DIV tag) and design (separate stylesheet) into different files. So, by using DIV tag we can reduce markup, load page faster and works well at different resolutions and network bandwidths. So, start using DIV elements for your page layouts and experience the benefits of it.  I am ending up the things here. I hope this article will be helpful for all.

Login to add your contents and source code to this article
Article Extensions
Contents added by Zuhair Darwish on Jul 02, 2009
Download File: div_html_page.zip
Header
Left Content
Main Content
Right Content
Footer
share this article :
post comment
 

So how to display a list of products in middle content do u mean we can use only div tags for listing also ?

Posted by prams b Feb 05, 2009
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Gauge for SharePoint
Become a Sponsor