I have two divs in a container. One is left bar and another is right bar. I need some advice/suggestions to use which method.
Method 1:
#container{ width:800px; margin:0 auto;}
#leftbar{ float:left; width:200px; }
#rightbar{ float:right: width:550px;}
Method 2:
#container{width:800px; margin:0 auto;}
#leftbar{ float:left; width:200px; }
#rightbar{ margin:0 0 0 210px; width:550px;}
Please advice which one is good practice.
If your container is always always always going to be 800px width then it really doesn’t matter which of the two options you use. Just use the one with the least bytes per file.
But if your container gets bigger than 800px, would you want the right bar to stick to the right hand side of the container? If so, only method 1 would work.
However there is another method that achieves the same effect as method 2 which is floating both divs to the left.