Controlling the width of table columns

Hi,

I need to control the width of columns in a table. The default behavior of IE is to adjust the size of the table columns to fit in the window. I need to specify a fixed size for the column of my table and if the total size of all columns exceeds the size of the window, a scrollbar should appear to allow the user to scroll.

To do so, I created a frameset and placed my table in a frame. I specified that the frame should scroll if required.

I included the source code for both the frameset and the frame below.

In the table, I specify that the width of each column in pixels. No scrollbar is ever created and the width of each column is decreased by the browser.

Any help is appreciated.

******** FRAMESET **********
<HTML>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Example </TITLE>
</HEAD>


<FRAMESET framespacing=1 border=0 frameborder=0>

    <FRAME  
    SRC="testTable.htm"
    NAME="testTable"
    FRAMEBORDER=0
    SCROLLING=yes
    ALIGN=top
    MARGINWIDTH=1
    >
   
</FRAMESET>

</HTML>

********** FRAMESET **********


********** FRAME testTable.htm ********
<HTML>
<HR SIZE=1 noshade><A NAME="Example_2"></A><B>Example 2</B>

<TABLE BORDER=1 cellpadding=3>
   <TR>      
         <TD WIDTH=400 VALIGN="top">
            Column 1
         </TD>
         
            <TD WIDTH=1200 VALIGN="top">
                  Column 2
            </TD>                  
       
        <TD WIDTH=400 VALIGN="top">  
                  Column 3            
        </TD>                              
   </TR>
</TABLE>
</HTML>

********** FRAME testTable.htm ********

rakhrasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

t1pimpCommented:
Well, you don't actually need to put it in a frameset at all. You could if you were using a frameset for navigation or something, but just for this it's not neccessary.  Set the table width equal to the sum of all your tabledata's.  2000.  

<table width="2000">


ex:
--------------------------------------
<HTML>
<HR SIZE=1 noshade><A NAME="Example_2"></A><B>Example 2</B>

<TABLE BORDER=1 cellpadding=3 width="2000">
   <TR>      
         <TD WIDTH=400 VALIGN="top">
            Column 1
         </TD>
         
<TD WIDTH=1200 VALIGN="top">
Column 2
</TD>                  
         
        <TD WIDTH=400 VALIGN="top">    
Column 3
        </TD>                                
   </TR>
</TABLE>
</HTML>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.