This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Design question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Design question" Watch "Design question" New topic
Author

Design question

Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
Hi all,
Recently I've adopted the use of <DIV>, replacing my old, rather ugly habit of nesting tables, upon tables, upon tables. It seems the pages I code using <DIV> exclusively, are more likely to be compatible across browsers. Anyone have any opinions? Do you rely more on stylesheets than traditional HTML? Are there any drawbacks to using <DIV>?
Thanks for your opinions,
WS


for (int i = today; i < endOfTime; i++) { code(); }
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
Divs and spans are the only way to go. A table was designed to display tabular information.
The best thing to do is just CSS you way throgh the page. It is so much easier to update a site that is done with CSS!
The drawbacks are it takes longer to get it to look right, but the positive side is faster loading times!
You may even want to dig into XHTML to make your pages even more compliant!
If you ever hhave trouble getting something looking right just ask it in the forum!
Eric
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
Thanks, Eric. I've been a barfly in the JSP forum for the past few months, schmoozing my way around JSP code and not really taking time to explore the other gigs going on around the Ranch. I believe I've found a new watering hole. Thanks again,
WS
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
My opinion: DIVs stink for layout. I've given up on using CSS to completely lay out pages. Too many browser inconsistencies for my taste. I use tables to layout things, and all the regular CSS constructs to format, etc. My opinion. Maybe in a couple years before everybody gets their act together I'll be able to do pure CSS, but until then, it's only wishful thinking for me.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50677

DIVs stink for layout.

Correction: IE stinks for layout. If IE would correctly support the bottom and right style rules, then using tables for anything other than, well, tables would be a thing of the past. (But heck, why improve a browser that's already "won" the browsers war? Isn't 'almost' good enough?)
I use CSS for layout whenever I can. On those occasions when IE bites me in the derriere, I usually use server-side browser detection to deliver a non-compliant but IE-safe version to IE.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
Well, from what I've seen, if done right, DIVs provide much cleaner code, and also greater compatibility among browsers. I've coded some large pages using nested tables, and when the boss comes to your desk and asks you why it doesn't work in Netscape, well, what can you say...just make them use IE? No, you've got to go in there with a shovel, well, make that a front-end loader, dig through the code and find out why Netscape and the other browsers don't like the table formats. It was a nightmare, and that's the reason I've been looking into DIVs. In my opinion, tables are just too much code and too inconsistent across browsers.
Allan Lykke Christensen
Greenhorn

Joined: Dec 10, 2003
Posts: 8
here is my 2 cents:
I started using DIVs sometime back because I wanted to clearer code and wanted to avoid the tables inside tables inside tables inside tables. I worked great for many things I did but there was one particular thing that bugged me (where I had to resort going back to tables). The situation was this:
- I wanted to creating a simple two column layout (using a DIV for each column)
- The left column contained a menu.
- The right column contained the content of the page.
- The left column had a fixed colour (say yellow) and the right column was plain white.
The problem occured when the right column contained more content that what could fit into the browser window. For some strange reason the left column didn't continue all the way down but only to what could fit into the browser window.
Anyways - those are things I'm sure can be dealt with if you are a CSS shark - but until things like these become a bit more standard I will stick to using tables.
Allan
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Originally posted by Bear Bibeault:

Correction: IE stinks for layout. If IE would correctly support the bottom and right style rules, then using tables for anything other than, well, tables would be a thing of the past. (But heck, why improve a browser that's already "won" the browsers war? Isn't 'almost' good enough?)
I use CSS for layout whenever I can. On those occasions when IE bites me in the derriere, I usually use server-side browser detection to deliver a non-compliant but IE-safe version to IE.

weird... IE is THE most compliant of all browsers out there... There are some quircks but not nearly as much as with the competition.
I guess it may be your understanding of the meaning of the classes rather than their implementation in IE that is at fault here.


42
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
Originally posted by Jeroen Wenting:

weird... IE is THE most compliant of all browsers out there... There are some quircks but not nearly as much as with the competition.
I guess it may be your understanding of the meaning of the classes rather than their implementation in IE that is at fault here.

LOL...IE is not the most compliant, there are people that are writing stylesheets to force it to act like like it should. The most compiant are the Mozzila browsers...
Eric
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
In my opinion, IE is just another mass-produced, conveniently-packaged, easy-to-handle piece of McSoftware that certainly serves the common good (just like those $.50 cheeseburgers), but when it comes to looking at it from a higher perspective, such as the developer's point of view, IE is sloppy, and sucks you into that M$ snare just like all their other pieces of point-and-click software -- sure it's easy to code, but once you leave MicrosoftLand, you're inevitably going to lose even more hair when you find out your software doesn't play well with others.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
check the standards docs, then check browser compliance.
You'll find IE in compliance with a larger part of the CSS1, CSS2, ECMAScript 1.5, XHTML, and other standards than any other browser on the market.
If that makes it easier to code against IE, is that a good thing or (as you claim) a bad thing?
You sound like just another "It's Microsoft so it must be bad" kiddie.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
Then why are people going these extremes?
http://dean.edwards.name/IE7/intro/
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50677

weird... IE is THE most compliant of all browsers out there...

Far, far from it. You've been standing too close to the Microsoft propoganda machine.
If they can't even get the bottom and right CSS rules correct, what's the point of looking further? (and if you do, the the list gets longer and longer and longer).
And let's not even start talking about event handling...
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
You sound like just another "It's Microsoft so it must be bad" kiddie.

I humbly accept the fact that I'm simply a novice, but, regardless, I have been in the trenches long enough to form an educated opinion on certain things, an opinion which is hardly the result of some anti-Microsoft bandwagon, but more the result of passing conversations, idle talk, and bar room arguments with those who have much more horsepower than I. I certainly respect the fact that Microsoft developers may be some of the brightest in the field, however, the company has always had an agenda -- to conquer the marketplace. They do so by marketing to the "point-and-clicker", and they're marketing their McSoftware fast enough and good enough to send the majority of the population to the fat farm.
Sure, I do use Microsoft products, and those I use aren't bad at all, but what I don't do is play ball and subscribe to the mass-production line mentality of feeding inferior software to the starving masses with the sole purpose of marketplace dominance.
WS
 
IntelliJ Java IDE
 
subject: Design question
 
Threads others viewed
using CSS float attribute makes things 'leak' out of their containers ?
Uneven spaces between tables
Another CSS/IE conundrum
Scroll bar with data table
how to add scroll bars in a JSP table?
MyEclipse, The Clear Choice