Click to See Complete Forum and Search --> : Need help on Tables


mararies5
04-06-2003, 08:48 PM
hello can someone help me please? I'm building a website and I want to know if one can use tables instead of frames? how is it possible (using tables) to make the links in the "left menu" "left row or cell" to load into the "right row or cell" and also how to make commands inside the table? like I put <.center> and it didn't work..of course w/o the .
and last but not least Is it true that tables are better to navigate with then frames?
I would really appreciate some answers
THANK YOU
:)

khaki
04-07-2003, 12:58 AM
Hi mararies5...

Since I'm a new CSS convert (still learning), I'm trying to pass along alternatives to Frame, Table, and Javascript menus whenever I see someone ask about them.

Below is a sample (very alterable) of a "mouseover-like" menu that is compact and simple.

The <style> below can be cut from the code and placed in a linked external CSS file (and referenced on every page - which is only 1 line of code), while the <div> can be unifromly positioned on every page in your site.

Just put the CSS link and <div> on every page - along with each page's content - and you will be free from the madness of Frames, Tables, and Javascript generated menus.

Even if you don't use this.... please don't use Frames! (the worst!).

all about the <style>...
;) k


<html>
<head>
<style type="text/css">
div#navMenu {
width: 25%;
background-color: #336699;
color: #000000;
float: left;
margin-left: 1%;
margin-right: 1%;
border: none;
}
div#navMenu a {
display: block;
background-color: transparent;
border: 1px solid #000000;
color: #000000;
font-family: tahoma, verdana, arial, sans-serif;
font-size: 75%;
text-decoration: none;
text-align: left;
padding: 4px 4px 4px 4px;
}
div#navMenu a:hover {
border: 1px solid #000000;
color: #ffffff;
background-color: transparent;
font-weight: bold;
}
</style>
</head>
<body>
<div id="navMenu">
<a href="home.htm">Home</a>
<a href="east.htm">East</a>
<a href="west.htm">West</a>
<a href="north.htm">North</a>
<a href="south.htm">South</a>
<a href="limbo.htm">Limbo</a>
</div>
</body>
</html>

PeOfEo
04-07-2003, 03:06 PM
If you want to use tables you will be using nested tables probably with like
<table>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>

and that will palce a table with three columns on your site andthen you can put more tables inside of each cell but DONT. I dont reccomend that because now everything is moving to css. I used to be big on tables myself but I dont think I will use them for layout anymore because they are a thing of the past and are not very professional.

khaki
04-07-2003, 03:38 PM
hey peo....

you feeling ok?

;) k

PeOfEo
04-07-2003, 05:16 PM
Well all of you guys have been bombarding me with css-ism that I think I am starting to see how affective it can be,.I have not used it yet for layout ( I have not started any sites for a long time) but I would like to get some css practice for layout because I already use it for just about everything else. I mean I use it on links scroll bars borders etc.

khaki
04-07-2003, 05:19 PM
so peo...

check-out the menu and tell me what you think (i didn't write it... but i did modify/enhance it over the paste few weeks).

do you know how to position <div> tags and refer to external CSS files yet?

let me know.
;) k

spufi
04-07-2003, 08:37 PM
"padding: 4px 4px 4px 4px;"

Hey khaki, I was looking through you code and saw that line. You can just use "padding: 4px;" and the 4px padding will be used on all sides. I also don't know why you used "background-color: transparent;" See if it makes a difference with it taken out in both of the places you have it. I haven't really used transparent yet, so I might not be the best to point it out either. :)

nkaisare
04-08-2003, 01:45 AM
Originally posted by spufi
I also don't know why you used "background-color: transparent;"
Probably bec CSS validator gives warning msg if you specify a color but not a background (or vice verca).

margin-left: 1%;
margin-right: 1%;
can be replaced by
margin: 0 1%

#336699 may be replaced by #369

Also, you shud use a proper doctype.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

In case you dont want to have your contents flow below your navigation float, you can specify margin-left: 27% for your body.

spufi
04-08-2003, 01:56 AM
Ah, I tend to ignore the warnings and just get rid of the errors. Granted I haven't needed to valid my CSS in awhile and it was probably before I even knew about using "transparent."

color: #000000;
color: #ffffff;

Can be shortened to...

color: #000;
color: #fff;

David Harrison
04-08-2003, 05:08 AM
I've got a few points so:

1) Aaaaaaaarggggh, my entire site is made out of tables in tables in tables!!!

2) What's wrong with tables.

3) What the hell does it matter if you don't have <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> at the start of your page?

spufi
04-08-2003, 11:29 AM
1. Ah, the sound of a person who uses nested tables. :)

2. Tables are good for what they are intended for which is tabular data. Tables for layout is bad. Why? Because they lead to things like nested tables. Tables screw over browsers for people with disabilities. Tables were used before CSS came along and made life a whole lot easier. As an example, create a large website without using CSS for layout. Now, go and change around your website even a little bit, ie background colors, link colors, the position of your menu. Was that a pain? You bet it was. Now create the same site using CSS and then make the same changes. If done correctly, all you have to do is change your external CSS file and you are done. This is what is meant by seperating style from content, and it makes your web page code a whole lot easier to weed through.

3. Adding the DOCTYPE tells the browser what version of HTML/XHTML you are using so it knows how to understand your code. What happens if you leave it out? Your browser then goes, "this person doesn't know what they are doing so I am going to assume certain things." This also means that it may try to read your code based on older versions of HTML than what you are using. Putting it another way. Let's say I code in a programming language like Java. I create some variables, but don't initialize them. Does this mean my program won't work? No, but there is a chance that something funky might happen, hence it's always good it initialize variables and it's always a good thing to add a DOCTYPE. Plus, you can't validate your page against W3C standards without one.

4. I figure I'll handle the validation question before you ask it. Why do it? Because it is what the web is moving towards and not away from. It helps teach you proper coding. It also make a browser's life easier. Plus, it helps in creating fewer cross browser issues.

starrwriter
04-08-2003, 09:45 PM
Originally posted by khaki
Hi mararies5...

Since I'm a new CSS convert (still learning), I'm trying to pass along alternatives to Frame, Table, and Javascript menus whenever I see someone ask about them.

Below is a sample (very alterable) of a "mouseover-like" menu that is compact and simple.
[/SIZE]

Here's a better non-javascript menu that changes colors of both text link and cell background:

<html>
<head>
<style type="text/css">
<!--
table{width:104px;}
table,td{border:2px solid black;border-collapse:collapse;padding:0;}
td{line-height:25px;vertical-align:50%;text-align:center;}
a{color:blue;background-color:white;text-decoration:none;display:block;width:100px;height:25px;}
a:hover{color:red;background-color:yellow;text-decoration:none;}
-->
</style>
</head>

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">

<table border="0">
<tr>
<th align="center" bgcolor="silver"><p>MENU</th>
</tr>
<tr>
<td><p><a href="#" id="one">Link One</a></td>
</tr>
<tr>
<td><p><a href="#" id="two">Link Two</a></td>
</tr>
<tr>
<td><p><a href="#" id="thr">Link Three</a></td>
</tr>
<tr>
<td><p><a href="#" id="fou">Link Four</a></td>
</tr>
<tr>
<td><p><a href="#" id="fiv">Link Five</a></td>
</tr>
</table>
</body>
</html>

mararies5
04-08-2003, 11:07 PM
but i really want to know is HOW TO GET THE LINKS ON THE LEFT SIDE OF THE MENU TO WORK...TO LOAD ON THE RIGHT SIDE OF THE PAGE?? HOW CAN I DO THAT..THESE ARE JUST MENUS AND CELLS .STYLES AND STUFF I WANT TO KNOW HOW TO MAKE THE LINKS IN THE MENU WORK...SO THEY CAN LOAD ON THE RIGHT SIDE ..OR THE MAIN PAGE?? HOW DO i DO THAT?

nkaisare
04-09-2003, 09:05 AM
I WANT TO KNOW HOW TO MAKE THE LINKS IN THE MENU WORK...SO THEY CAN LOAD ON THE RIGHT SIDE ..OR THE MAIN PAGE?

The reply was already posted
Dave Clark
Strictly speaking... You cannot have true navigation that loads in a table cell. Only objects that have a location object can be the recipient of navigation results. On the other hand, via JavaScript, you can usually simulate navigation that would output into a table cell. However, if you do that, your page will not work at all in browsers that either do not support JavaScript or the visitor has purposely disabled JavaScript execution for one reason or another.

One possible non-JavaScript solution is to have an IFRAME in a table cell to receive the navigation results.

Dave

Other people's replies give you a way to have navigation links on the same page as you contents. Of course you will have to make changes to all pages on your website to include this.

For example, if you had a webpage (mypage.html)
<html>
<head>
...
</head>
<body>
...
</body>
</html>

and navigation page (body of which is:)
<p><a href="...">Link 1</a></p>
<p><a href="...">Link 2</a></p>
<p><a href="...">Link 3</a></p>

Your new "mypage.html" should read

<html>
<head>
...
</head>
<body style="margin-left: 150px">
...
<div style="position: absolute; top:0; left:0; width: 140px; padding: 5px;">
<p><a href="...">Link 1</a></p>
<p><a href="...">Link 2</a></p>
<p><a href="...">Link 3</a></p>
</div>
</body>
</html>

(where ... represent contents of original "mypage.html"

khaki
04-09-2003, 11:20 AM
starrwriter wrote: Here's a better non-javascript menu that changes colors of both text link and cell backgroundactually... it's not better.... because it relies on tables for laying-out navigational links.

The example I provided (with it's missing elements... i know... i know... it was stripped-down for space considerations. sorry. but thanks for clarifying all of the ommitted/messy stuff nkaisare and spufi!)...

Anyway, that solution can have the background change as well.
Just change:
background-color: transparent;
to
background-color: green;

Like I originally said... this is "very alterable".
(and does not rely on tables!)

As to mararies5's concern about how this doesn't change the right side of the page:

If you don't use Frames pages (and you really shouldn't), then you have the options of using iframes or putting this very compact and small menu on every page (which will always mean that it will require the creation of at least one less page than if you had used Frames in the first place).

Personally, I'd suggest placing the <style> in an external file, write specific <div> coordinates for the menu, and just place it on every page along with each page's unique content.
OR...
If you have ASP capabiltity, just stick it all in one include file and reference it with just one line on every page:
<!-- #include file="entireMenu.inc" -->
and any changes that need to be made to the menu and/or style (site-wide!) can be done from the single include file.

That's one opinion (and how I have been writing (and re-writing) my pages to-date).

okay... enough said on that :) ...
;) k

khaki
04-10-2003, 10:06 AM
Hi mararies5...

Wow... you are persistent! lol
You want a table solution so badly that you PM'd Dave Clark directly? :eek:

Well... I'd be negligent to not offer the non-table alternative (since I no longer believe in using tables for navigational links... just data)... and besides... I'm assuming that I just haven't recieved your PM asking for it yet ;).

So... here is the CSS menu using your iframe preference.
It may seem longer than the table version that Dave provided at your request... but it also contains all of the formatting and positioning.

Obviously you will use whatever way that you feel more comfortable with... but at least I have satisfied my obligation to alter an alternative :) .

(nkaisare and spufi may want to double-check me again :rolleyes: ... since... let's face it... i need careful watching :eek: lol)

this should work "right out of the box" so all you need to do is modify it for your own needs.
Happy scripting...
;) k

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
div#navMenu {
position: absolute;
top: 5px;
left: 0px;
width: 25%;
background-color: #369;
color: #000;
float: left;
margin-left: 1%;
margin-right: 1%;
border: none;
}
div#navMenu a {
display: block;
background-color: transparent;
border: 1px solid #000;
color: #000;
font-family: tahoma, verdana, arial, sans-serif;
font-size: 75%;
text-decoration: none;
text-align: left;
padding: 4px 4px 4px 4px;
}
div#navMenu a:hover {
border: 1px solid #000;
color: #fff;
background-color: transparent;
font-weight: bold;
}
div#navContents {
position: absolute;
top: 5px;
left: 210px;
}
</style>
</head>
<body>
<div id="navMenu">
<a href="http://www.nypost.com/" target="myIframe">This is the link for page 1</a>
<a href="http://www.oddtodd.com/" target="myIframe">This is the link for page 2</a>
<a href="http://www.comics.com/comics/getfuzzy/index.html" target="myIframe">This is the link for page 3</a>
<a href="http://webbedenvironments.com/dhtml/code/DHTML_CSSCode/index.html" target="myIframe">This is the link for page 4</a>
<a href="http://www.dooce.com/" target="myIframe">This is the link for page 5</a>
<a href="http://www.toysfortots.org/2002/index.html" target="myIframe">This is the link for page 6</a>
<a href="http://birdcam.kodak.com/cgi-bin/asCgi.pl?node=1&app=birdcam&laf=playground" target="myIframe">This is the link for page 7</a>
<a href="http://www.afn.org/~afn30091/80songs.html" target="myIframe">This is the link for page 8</a>
<a href="http://www.groovechamber.com/easter/" target="myIframe">This is the link for page 9</a>
</div>
<div id="navContents">
<iframe name="myIframe" src="http://www.DaveClarkConsulting.com" height="400" width="575">
</iframe>
</div>
</body>
</html>

nkaisare
04-10-2003, 10:25 AM
Originally posted by khaki
I realize its wishful thinking that mararies will do away with tables any time soon :) :( :confused:

Just an aside:
As long as HTML books claim "best way to learn HTML is to look at the source code", we will keep having this problem. Biggest of firms (amazon.com for example) still use tables in fact several levels of nested tables. They may require people to have NS6 or IE5 or higher so that their nifty little javascripts work, but they will continue using tables becuase Version 4- browsers do not support CSS positioning to a satisfactory level!! :rolleyes:

spufi
04-10-2003, 11:23 AM
I only saw some very minor things in your code khaki. Again, unless I'm missing something, "padding: 4px;" should work because it means putting padding on all fours sides. In the iframe you had the numbers for the size, but not the type. I added "px" to both. Again, minor things at best. I then went and validated the page, and then changed it to link the CSS externally. Here's the breakdown...

Create a file named styles.css and put this code in it.

div#navMenu {
position: absolute;
top: 5px;
left: 0px;
width: 25%;
background-color: #369;
color: #000;
float: left;
margin-left: 1%;
margin-right: 1%;
border: none;
}
div#navMenu a {
display: block;
background-color: transparent;
border: 1px solid #000;
color: #000;
font-family: tahoma, verdana, arial, sans-serif;
font-size: 75%;
text-decoration: none;
text-align: left;
padding: 4px;
}
div#navMenu a:hover {
border: 1px solid #000;
color: #fff;
background-color: transparent;
font-weight: bold;
}
div#navContents {
position: absolute;
top: 5px;
left: 210px;
}

Now here's your actual HTML code.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>My Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" title="Default" media="screen" href="styles.css" type="text/css">
</head>
<body>
<div id="navMenu">
<a href="http://www.nypost.com/" target="myIframe">This is the link for page 1</a>
<a href="http://www.oddtodd.com/" target="myIframe">This is the link for page 2</a>
<a href="http://www.comics.com/comics/getfuzzy/index.html" target="myIframe">This is the link for page 3</a>
<a href="http://webbedenvironments.com/dhtml/code/DHTML_CSSCode/index.html" target="myIframe">This is the link for page 4</a>
<a href="http://www.dooce.com/" target="myIframe">This is the link for page 5</a>
<a href="http://www.toysfortots.org/2002/index.html" target="myIframe">This is the link for page 6</a>
<a href="http://birdcam.kodak.com/cgi-bin/asCgi.pl?node=1&app=birdcam&laf=playground" target="myIframe">This is the link for page 7</a>
<a href="http://www.afn.org/~afn30091/80songs.html" target="myIframe">This is the link for page 8</a>
<a href="http://www.groovechamber.com/easter/" target="myIframe">This is the link for page 9</a>
</div>
<div id="navContents">
<iframe name="myIframe" src="http://www.DaveClarkConsulting.com" height="400px" width="575px">
</iframe>
</div>
</body>
</html>

Now, I have no idea what your final page will look like, but I'm not a real big fan of frames, or iframes. Case in point, looking at the posted code, some of the links not only require you to scroll up and down, but side to side. If you keep this in mind, make sure whatever goes into the iframe at least fits it horizontally. I would be tempted to make it fit vertically too, but that's coming from a person who only uses frames when I have to like for a class, or something.

khaki
04-10-2003, 12:02 PM
thanks spufi...

i didn't test what you edited yet, but i'm pretty confident that it's working (i think that you are probably more careful than i am about posting possibly flawed code :rolleyes: ).

and the links in my example were naturally going to scroll (both ways).
i just stuck real web links in there to display something to provide a working example.
and i also use mine with an external css file (ya gotta love css for making life so much easier!)

but...you say that it passes validation?
(i never really checked it. i really need to start doing that i guess :rolleyes:

and... like nkaisare said, weaning people away from tables is a lonely business :( .

well... at leat I enjoyed this little excercise! :)
(even if mararies5 goes a different way)

always enjoys a good collaberation...
;) k

spufi
04-10-2003, 12:52 PM
I know those were just example links, and that's why I didn't really look at them as being final and just mentioned that whatever is used, at least in my view, should fit horizontally.

My code still doesn't technically validate due to the fact that link number 7 has a "?" in it. W3C's validator flags it. Since I know it's because you are linking to a page that involves CGI, I just let it slide.

I hear you guys about annoying teachings. I was looking at certain IT certifications and I see that for HTML they use HTML 4.0. Now, teaching 4.0 isn't really all that bad, but considering how long 4.01 has been around, you would hope people start teaching others how to code valid 4.01 with CSS from the start.

khaki
04-10-2003, 01:05 PM
considering how long 4.01 has been around, you would hope people start teaching others how to code valid 4.01 with CSS from the startBack in my bartending days we never hired anyone that came from a bartending school.

In my last 2 positions (corporate web development) we never hire anyone that comes from computer schools.

The real world, and the school world seem to contain too much of a disparity that unfortunately requires the need to "correct" and "re-teach" the bad habits and outdated stuff that comes with such people.

It's those that are "self-taught" that seem to have a firmer grasp (albeit with gaps in knowledge) that seem to assimilate and produce quicker.

Just my own observation of what you mentioned (and why that may be so).
;) k

mararies5
04-10-2003, 11:30 PM
Dave Thank you so much!!! YOU SAVED ME!!!!! THANK YOU THANK YOU!!!
You're my hero now
HEHE
THANX
:)

mararies5
04-10-2003, 11:33 PM
khaki thank you too!! your codes really helped me out too and of course i followed your advice on CSS..thanx for all the help everyone!!!

:D