My name is Sandesh Ajgaonkar
The most difficult thing in CSS to get right is the layout of your site. Here are a couple of tips dealing just with that. Some of these tips are not exactly new, or rocket science, but hopefully they will save someone a bit of bother somewhere! Tip 1: Clear out the default padding and margin settings before you start working. Different browsers have different default margin and padding sizes so you want to start with a clean slate, so to speak. Use this command: * { margin: 0; padding: 0; border: 0; } to clear all default margin and padding settings. Also note the border, which is set to 0. Please note that if you do this, you will also get rid of the pesky purple border round click-able images, although some people argue that the purple border is necessary for accessibility and usability. But lots of people do not like the purple border round images, and this is one way that you can get rid of it in one fell swoop without having to set img border=0 for each image (which is against the strict markup rules in any case). Tip 2: To center your layout, use a container div to contain all your content Declare it as follows: #container { margin: 0 auto; width: xxxpx; } There are a couple of points here to take note of. DO NOT declare the width to be 100%. This defeats the whole object since you will just have to declare the sub elements within the container and then center THEM using margin : 0 auto. This is VERY BAD since it means that instead of declaring the central layout once, you will have to declare it in multiple places for each element within your container. Tip 3: Work from the top down Literally start working on your CSS layout starting from the top most elements in your design, as well as the 'top' elements in your HTML, such as the body, as well as your main containers. Declare your CSS commands on the highest level possible and try and declare something once only and let it cascade throughout. Only override the commands at a lower level when strictly necessary. This prevents a verbose CSS file that is difficult to maintain and understand. For example, if you have { margin : 0 auto} settings on each and every sub div within your container - you are in trouble. Tip 4: Document what you are doing and use Firebug and the Firefox browser to debug You are not writing your CSS code just for yourself, some day some poor sod will have to debug it. Make numerous comments inside your CSS file to explain why you are doing things in a specific way. Fitting in with this, you might find yourself having to fix someone else's CSS more often than you think (or even your own, for that matter). Use the Firebug add-on for Firefox to debug your CSS. This is a life-saver with regards to giving you an insight into exactly where your design might be broken and why. The only problem with this is that your design might work perfectly in Firefox, but not in IE5, IE6 or IE7. This brings us to the next tip. Tip 5: Decide which browsers you are going to build your CSS for and test from the start Some purists insist on making sure that your website work for all possible browsers, others only make it work for the 'major' browsers. How do you know exactly which browsers are used the most? Once again W3 Schools come to the rescue. On the following page, you can see which browsers are the most popular: http://www.w3schools.com/browsers/browsers_stats.asp. From this page you can see that something like IE5 is only used by about 1.1% of browsers. It is up to you whether you consider it worthwhile to build your CSS to be compatible with this browser, or whether you are just going to test your compatibility with IE6, IE7 and Firefox, for example. Whatever you do, when you start building your CSS, start from the top, and test each and every setting in each of the browsers as you go along. There is nothing worse than building a perfect website in Firefox, then finding out right after you have coded a 1000 line css file that it is broken in IE6. To then debug and fix your code after the fact is a nightmare. Tip 6: Here is an embarrassing little tip for fixing your CSS in IE6 or IE7 Let's say your design works perfectly in Firefox, but is broken in IE6. You cannot use Firebug to determine where the problem might be since it WORKS in Firefox. You do not have the luxury of using Firebug in IE6, so how do you debug an IE6 or IE7 stylesheet? I often found that it helps to add {border : 1 px solid red} or {border : 1 px solid purple} to the problematic elements. This way you can often see why certain elements do not fit into the space available. It is an embarrassing little tip since it is so primitive and simple, but it works! Tip 7: Understand floats Floating of elements is essential to understand, especially in the context of getting your floated elements to work in the different browsers! Basically elements such as divs are floated to the left or the right (never to the top or the bottom, only sideways). Here are a couple of things to take into consideration with floated elements. Each floated element must have an explicit width specified. If you are making use of floated divs to create a 3 column or a 2 column layout, rather specify the widths in terms of percentages rather than fixed widths, and if you do use percentages, make sure that the percentages do not add up to 100%, this will often cause the right most column to drop below the rest, clearly indicating that you are trying to fit something into the available space that is too wide for it. Rather use percentages that add up to slightly below 100%, such as 25%, 49%, 24% for a left column, middle column and right column. Floating elements can be extremely complex to understand and it is worth while to spend some time on good sites that provide specific guidelines and tips, such as the Position Is Everything website. Conclusion These CSS tips for layout should hopefully save you some time and effort when you next have to panel-beat a table-less design into submission!
The most difficult thing in CSS to get right is the layout of your site. Here are a couple of tips dealing just with that. Some of these tips are not exactly new, or rocket science, but hopefully they will save someone a bit of bother somewhere!
Tip 1: Clear out the default padding and margin settings before you start working.
Different browsers have different default margin and padding sizes so you want to start with a clean slate, so to speak. Use this command:
*
{
margin: 0;
padding: 0;
border: 0;
}
to clear all default margin and padding settings. Also note the border, which is set to 0. Please note that if you do this, you will also get rid of the pesky purple border round click-able images, although some people argue that the purple border is necessary for accessibility and usability. But lots of people do not like the purple border round images, and this is one way that you can get rid of it in one fell swoop without having to set img border=0 for each image (which is against the strict markup rules in any case).
Tip 2: To center your layout, use a container div to contain all your content
Declare it as follows:
#container
{
margin: 0 auto;
width: xxxpx;
}
There are a couple of points here to take note of. DO NOT declare the width to be 100%. This defeats the whole object since you will just have to declare the sub elements within the container and then center THEM using margin : 0 auto. This is VERY BAD since it means that instead of declaring the central layout once, you will have to declare it in multiple places for each element within your container.
Tip 3: Work from the top down
Literally start working on your CSS layout starting from the top most elements in your design, as well as the 'top' elements in your HTML, such as the body, as well as your main containers.
Declare your CSS commands on the highest level possible and try and declare something once only and let it cascade throughout. Only override the commands at a lower level when strictly necessary. This prevents a verbose CSS file that is difficult to maintain and understand. For example, if you have { margin : 0 auto} settings on each and every sub div within your container - you are in trouble.
Tip 4: Document what you are doing and use Firebug and the Firefox browser to debug
You are not writing your CSS code just for yourself, some day some poor sod will have to debug it. Make numerous comments inside your CSS file to explain why you are doing things in a specific way.
Fitting in with this, you might find yourself having to fix someone else's CSS more often than you think (or even your own, for that matter). Use the Firebug add-on for Firefox to debug your CSS. This is a life-saver with regards to giving you an insight into exactly where your design might be broken and why.
The only problem with this is that your design might work perfectly in Firefox, but not in IE5, IE6 or IE7. This brings us to the next tip.
Tip 5: Decide which browsers you are going to build your CSS for and test from the start
Some purists insist on making sure that your website work for all possible browsers, others only make it work for the 'major' browsers. How do you know exactly which browsers are used the most? Once again W3 Schools come to the rescue.
On the following page, you can see which browsers are the most popular: http://www.w3schools.com/browsers/browsers_stats.asp. From this page you can see that something like IE5 is only used by about 1.1% of browsers. It is up to you whether you consider it worthwhile to build your CSS to be compatible with this browser, or whether you are just going to test your compatibility with IE6, IE7 and Firefox, for example. Whatever you do, when you start building your CSS, start from the top, and test each and every setting in each of the browsers as you go along. There is nothing worse than building a perfect website in Firefox, then finding out right after you have coded a 1000 line css file that it is broken in IE6. To then debug and fix your code after the fact is a nightmare.
Tip 6: Here is an embarrassing little tip for fixing your CSS in IE6 or IE7
Let's say your design works perfectly in Firefox, but is broken in IE6. You cannot use Firebug to determine where the problem might be since it WORKS in Firefox. You do not have the luxury of using Firebug in IE6, so how do you debug an IE6 or IE7 stylesheet? I often found that it helps to add {border : 1 px solid red} or {border : 1 px solid purple} to the problematic elements. This way you can often see why certain elements do not fit into the space available. It is an embarrassing little tip since it is so primitive and simple, but it works!
Tip 7: Understand floats
Floating of elements is essential to understand, especially in the context of getting your floated elements to work in the different browsers!
Basically elements such as divs are floated to the left or the right (never to the top or the bottom, only sideways). Here are a couple of things to take into consideration with floated elements. Each floated element must have an explicit width specified. If you are making use of floated divs to create a 3 column or a 2 column layout, rather specify the widths in terms of percentages rather than fixed widths, and if you do use percentages, make sure that the percentages do not add up to 100%, this will often cause the right most column to drop below the rest, clearly indicating that you are trying to fit something into the available space that is too wide for it. Rather use percentages that add up to slightly below 100%, such as 25%, 49%, 24% for a left column, middle column and right column.
Floating elements can be extremely complex to understand and it is worth while to spend some time on good sites that provide specific guidelines and tips, such as the Position Is Everything website.
Conclusion
These CSS tips for layout should hopefully save you some time and effort when you next have to panel-beat a table-less design into submission!
Did you find this article useful? For more useful tips and hints, points to ponder and keep in mind, techniques, and insights pertaining to credit card, do please browse for more information at our websites.
<a onClick="javascript:pageTracker._trackPageview('/outgoing/article_exit_link');" href="http://www.yoursgoogleincome.com
">http://www.yoursgoogleincome.com
</a>
<a onClick="javascript:pageTracker._trackPageview('/outgoing/article_exit_link');" href="http://www.freeearningtip.com
">http://www.freeearningtip.com
</a>
- Related Videos
- Related Articles
- Ask / Related Q&A
- Internet Web Conferencing Software – Advantages of Having Video in Web Based Conferencing Services
- Internet web site marketing tips - selecting keywords
- Home Based Business-Online Internet Web Marketing is a Must!
- 3 Unbeatable Internet Web Site Marketing Tips
- Internet Web Page Design
- Help Build a Successful Online Business With Internet Web Site Promotion
- Internet Web Site Design
- Three Reasons Why They Hate your Internet Web Site Design




Paid Survey Companies: An Assessment and Analysis
By: Ewen Chia | 15/12/2009The business of paid survey is piping hot now-a-days. There are many companies that are just waiting for you to sign up and complete the surveys. These are market research firms hired by corporate groups or corporate groups themselves for examining the status of market for their product.
Bringing Gains: Paid Research Survey
By: Ewen Chia | 15/12/2009Surveys are a kind of market research where the organizers want to know the opinions and belief of the users whom he will sell his product or who have been purchasing his services. If companies sponsor some rewards to know what you have been thinking all long, it doesn’t seem a bad idea, though!!
Analyzing The World Of Paid Market Surveys
By: Ewen Chia | 15/12/2009The trend of making extra money has experienced a new surge by the arrival of paid surveys. These paid surveys are organized by several corporate groups or market research firms for a better understanding of their products and consumer expectations. These surveys help in- house research team of organizations to get a real-look into market demands and supplies.
Paid Online Surveys: Paying the Efforts
By: Ewen Chia | 15/12/2009Paid online surveys are a kind of statistical data accumulation of consumer behavior. Surveys are conducted to outline the needs and expectations of consumers specific to a product. The organizing companies or brand survey agencies reward the survey takers to compensate their time consumed and value their opinion, thus the consumers or signed surveys users get paid and when the mode of conducting survey and collecting data is internet, the surveys are called paid online surveys.
Why Is Wenetprofits Global Business So Amazing?
By: Colon Bolden | 15/12/2009Increasingly more people are using the Internet to gain financial freedom. If you are one of them, maybe you should try one of the latest business opportunities. Wenetprofits is an exceptional program for those who want to make money and help people in need at the same time. There is...
Treat Your Home Business As An Urgent Matter
By: Aziz Jangbar | 14/12/2009In order for anyone to succeed in any kind of Home Business, they have to learn how to give priority to their business. Because of the time flexibility available in a home business, many people fall into the trap of getting other things done first before they work on their business. Which results in failure or loss of income. If success in a home business is important to someone, then they need to give it priority over unimportant things.
Ecommerce Website Design - Live Chat is an Asset to Grow Your Sales
By: Daljeet Sidhu | 14/12/2009The first step in e-commerce development is diverting traffic to the website. However, the success of an e-commerce website depends on how effectively it can engage the interest of customers, and convert that interest into a sale. This can be achieved by incorporating special design elements such as live chat...
Ecommerce Website - Top 8 Design Tips to Make You Successful
By: Daljeet Sidhu | 14/12/2009E-commerce solutions are an effective way of increasing business revenue and expanding your clientele. The design of an e-commerce website is crucial in getting customers to your website and keeping them there. Businesses cater to consumers of all ages through their e-commerce solutions. Teenagers have pretty much seen computers from the...
How you are Focus on You Give Power To!
By: jsolutions014 | 30/10/2009 | BusinessThe unconscious mind has an unlimited ability to hold information; it never sleeps, and it is always absorbing information and data. Your unconscious intends to protect you in any way that it can; it kept you from falling off the bed last night, didn’t it? It was aware of the edge of the bed and kept you away from it, just far enough to be safe.
Eight Tips for Natural Skin Care...
By: jsolutions014 | 30/10/2009 | HealthThe skin is the mirror of our health center and well being, both physical and emotional. The skin is a part of the body, such as the liver, heart and kidneys. When blood flow is blocked to the skin for any reason, the skin hardens, thickens and loses its normal appearance. As you get older in years.
Four ways to increase & diversify Your Consulting Income
By: jsolutions014 | 28/10/2009 | BusinessHere are just a few ways to increase and diversify your income from your consulting business.
How Make Webmaster Staffing Success: -It’s All About Staff Management
By: jsolutions014 | 27/10/2009 | InternetWeb owners are always in search of new and effective strategies to take the load off of their shoulders or just have some extra pair of hands to help them out on their website management ventures.
My Identity Was Stolen Because Of Someone Else's Mistake..
By: jsolutions014 | 24/10/2009 | ComputersGiving Total Strangers Your Personal Information How often would you say you trust total strangers with some of your most confidential information? I think I can answer this question for just about everyone. The answer is, nearly everyday.
Pure Performance: - In 1999 the Nissan Skyline R34 GTR came to life
By: jsolutions014 | 22/10/2009 | Sports & FitnessIn 1999 the Nissan Skyline R34 GTR came to life, the latest model, and the best GTR yet. Styling is superb with an all-new much more aggressive shape; it looks like a car to be reckoned with. The R34 GTR looks and feels like it got the best from both of the R32 and R33 models in one package.
They don't travel for hours in cramped conditions..
By: jsolutions014 | 22/10/2009 | BusinessWe have all heard the warnings about DVT (deep-venous thrombosis) when traveling on long haul flights. Cramped conditions for hours on end with very little leg movement - yes I've seen the in-flight videos demonstrating the exercises. Well if these warnings concern you give a thought to astronauts!
Golf Accessories: - Clubs Shoes Bags & more
By: jsolutions014 | 21/10/2009 | GolfWhen you think about golf accessories, what do you think of first? Which aspects of golf accessories are important, which are essential, and which ones can you take or leave? You be the judge.