05

th

Jan

The 6 don’ts of Web Development

The 6 don’ts of Web Development

Over the years i have found (usually the hard way) that there are a lot of guidelines we need to remember whenever we are working with the web. So keep these in mind next time you're building a website!

Don’t forget to clear your floats.

So maybe you have gotten use to clearing your floats, personally I think a lot of people either never understood the concept fully or stuck too long with tables because you can’t run into that problem with them. Anyways here is the don’t. Whenever you have a float you should remember that the floated element kind of literally floats in the page, hence if there is a wrapping element it will not get pushed down under the floated element, here is a picture to help you visualize this.

floated-non-cleared 

And if you want to see it in code here you go smile :

<div class="wrap" style="border:1px solid #666; width:200px;">
<div class="floated" style="float:left; height:200px; border:1px solid #CCC; width:150px; margin-left:10px;"></div>

 

So the idea here is that the floated element, well its floating hence you will need to clear it i just recently found a very interesting solution (compared to using the old class clear that has the clear:both; property in the css styles) you can use the br tag with the attribute clear and then you choose whether its a left float a right float or both which happens when you have an element or 10 that are floated left and right. Here is how that looks:

<br clear="all" />
<br clear="left" />
<br clear="right" />

 

Seems to work pretty well, so have fun and remember clear your floats.

Don’t use tables for your website layout… any part of it

So i’m sure 90% of you are like “Obviously!!” but i keep running into web developers that either still use tables for everything (which is such a headache to work with) or they use a hybrid which is something i didn’t even know existed until recently. The hybrid consists of using div’s for the main layout elements but inside those divs you lay a heavy groundwork of tables. Anyways the headache is still the same, tr tr, td, td, tr ,td td… IM LOST let me be td’s. Anyways please don’t use tables for your layouts, tables can only and should only be used in a few scenarios, forms (although you can do a pretty smack up job of making forms work well with divs and labels, i’ll have to write an article on that) and tabular data of course. Last but not least you can use it for calendars… and that’s it. Anything else is not okay, so please spend some time read some tutorials and learn to use divs the web is moving forward move with it.

Don’t overuse absolute positioning

I’ll admit it is  a little addicting to use absolute positioning because its the easy way out. But its usually not the best solution. I try to use absolute positioning only when there really is no alternative available for me. Absolute positioning for some odd reason has some minor cross browser issues, and there are other reasons i won’t go into. Try to  float elements, and use good markup that positions elements naturally. Absolutely positioned elements can be a huge frustration later in the cycle of building a website.

Don’t forget that not everyone has JavaScript enabled

For the most part i’ll admit that most people have JavaScript enabled, but it’s always a good policy to make sure if javascript isn’t enabled to either notify the user and ask them to enable it, or to create alternative methods of accomplishing what the javascript was suppose to do. Using the noscript tag is a sure way to accomplish either.

<noscript>Hey turn that JavaScript ON!!!</noscript>

Don’t overestimate the browser compatibility of your users

Even though websites are dropping IE6 support like wild fire you should see if dropping support for browsers is okay with your visitors. Check your analytics, or just make sure there is minimal support. Minimal support means that even though the website is not pixel perfect the same in every browser at least it is fully functional. Personally i believe that ecommerce websites always need to support most browsers. Web Development blogs on the other hand… well i personally don’t support ie6 on this blog. Anyways make sure that you are supporting all browsers at least minimally!

Don’t forget that your website will be viewed by all types of monitor sizes

I have definitely gotten much better at this as of lately. You should realize that your website will be seen by monitors of all sizes, from tiny laptop monitors, to gigantic web developer monitors. Recently I had to modify my fully fluid layouts to a restricted width, no one likes reading a huge paragraph in one line of text, it’s just not fun. I’ve actually found that the websites i design on my laptop do best against multi-browser size monitors. Hence i have one big monitor and one smaller 17 inch monitor on my desk as of the time i’m writing this article. Again looking over your analytics can really help you figure out which size you want to mainly aim for, 800x600 IS a thing of the future wink so consider that next time you design.

Related Articles

Comments

By Chris on Tue - Jan 05th, 2010

Re “Don’t forget to clear your floats” Even better, use “overflow: auto;” like so, and then you don’t need to clear the float:

<div class=“wrap” style=“border:1px solid #666; width:200px; overflow:auto;”> 
<div class=“floated” style=“float:left; height:200px; border:1px solid #CCC; width:150px; margin-left:10px;”></div>

By Angel Grablev on Wed - Jan 06th, 2010

@Bock, there are quite a few fixes for that smile either with js or min-height and the css fix for ie smile

By Bock on Wed - Jan 06th, 2010

I have to use tables when the content should stretch to height of the container. 

There is no other way.

By Daniel S on Thu - Jan 07th, 2010

I think in XHTML 1.0 Strict the br clear=“all” is not accepted..?

Why to use an semantic br-Tag, if you can clear your floats easy with css?

By GenoBaby on Fri - Jan 08th, 2010

Tables should still be used to display tabular data. Also since CSS has issues with displaying vertically aligned text in the middle of a div sometimes a quick fix that works on all browsers is to just put it in a table with one cell and set the cell vertical alignment to middle. No CSS hacks needed to make sure it works across all browsers correctly.

By aravind on Fri - Jan 08th, 2010

I strongly disagree on using
s for clearing float. It is so 1999. overfolw:hidden is the better solution.

and 7. don’t overuse captcha..
using captcha for Wordpress blog comments? Come on dude! Akismet is still ailve!

By Dongan on Sat - Jan 09th, 2010

When we are playing with data especially 1000s from database, table is the only way to control!. The rest we always encourage to play with!

By purpler on Sat - Jan 09th, 2010

<quote>
/* Clear Fix */
.clearfix:after {
content:”.”;
display:block;
height:0;
clear:both;
visibility:hidden;
}

* html .clearfix {height:1%;}
</quote>

.clearfix has proven its strength and usability in various scenarios and its highly recommended by bunch of web masters and should be taken as a standard.
my 0.02$

By Bruce on Sat - Jan 09th, 2010

Re #1, the clear attribute is deprecated.
http://reference.sitepoint.com/html/br/clear

By Chris on Sun - Jan 10th, 2010

.clearfix is a hack. Just use overflow:hidden. It’s much much simpler and it works. I am constantly amazed that so few people know about it.

Also what’s with the dates in these comments? They’re all the 31th (?) of January.

By Chris on Sun - Jan 10th, 2010

Just more on the .clearfix thing, if you look at the Position Is Everything post where it comes from http://www.positioniseverything.net/easyclearing.html you’ll see they even tell you that the information is out of date and link to a Sitepoint article which uses overflow:auto http://www.sitepoint.com/blogs/2005/02/26/simple-clearing-of-floats/

By Phil on Mon - Jan 11th, 2010

Being devil’s advocate her for a minute - you mention don’t use tables or absolute positioning without really explaining why not (in fact you say you wont go into why not use AP Divs). I did a little survey with my students on SEO and table-based websites came top of Google as well as CSS-based. Google doesn’t differentiate and for some new web developers tables are a lot easier to understand that CSS. I know CSS is more semantic but every time I hear the words ‘don’t use tables’ it’s without any really solid reasoning and seems to be going with the crowd. Table-based websites show up in browsers, are accessible, are Google-friendly, and until someone comes up with a REALLY interesting reason as to why not to use tables I’m not sure I should go to the fairly intensive exercise of trying to understand the intricacies of CSS.

By Chuck Spidell on Mon - Jan 11th, 2010

Don’t forget that you can absolutely position elements in a relatively positioned element.

By schmackLab on Mon - Jan 11th, 2010

@Phil
I highly reccommend reading this book by Dan Cederholm. It has an entire chapter on Tables that uses them in many different ways and lists the pluses and minuses of each method. Like you I always have to know why I’m doing something. This book gives you all the reasons why and thus the ability to make an educated decision based on your current project and circumstances as to what the best method is.

As far as a reason one of the better ones is that tables make it very difficult for screenreaders, handheld devices and computers that do not allow css to view your page properly.

Using standards helps to bullet proof your site and isn’t just a way to make you look good to the few people out there who like to view source.

The book on amazon:
http://www.amazon.com/gp/product/1430219203/ref=ox_ya_oh_product

By Jurre Smit on Fri - Jan 15th, 2010

Really? Seriously? These are the dont’s for webdevelopment? It is 2010 people! We had this discussion 10 years ago…

Everyone will agree with you and the clearfix is outdated… This is an open door! We have been here! Talk about something new…

By SMiGL on Thu - Jan 21st, 2010

Nice post.

By Brampton Web Design on Tue - Jan 26th, 2010

Excellent article, these should really be adapted especially with regards to monitor sizes. There are still developers who forget about this basic rule “Don’t forget that your website will be viewed by all types of monitor sizes”.

By HazelJames28 on Sat - Mar 06th, 2010

Every body understands that men’s life seems to be not cheap, but people need money for various stuff and not every person earns big sums money. Hence to receive fast mortgage loans or just car loan would be good solution.

Have something to share?

Remember my personal information

Notify me of follow-up comments?

Please enter the word you see in the image below: