Posts Tagged Css Style
Programming tips
Posted by in General on December 13th, 2009
- Name your functions and variables with meaningful names so that people will understand the function or variable just by reading it’s name. If a function return best selling product, name it like get_best_selling_products().
- Do a lot of comment for your code, especially if you are working in a team. By commenting you are making other peoples life more easy.
- Make your function small where you can see all code for that function in one screen without scrolling. When the function is getting bigger than your screen, its time to split it into smaller function.
- If your chunk of code is often use, then create a function for it so every part of your application can call this function. An example of this is database connection and query.
- Put your javascript code and css style in different file. Save your javascript as .js file and your css file as .css file.
How to use different css on different browser
Cross Browser Compatibility is a huge issue in the website development with many browsers in the market. But luckily most of them uses Internet Explorer and Firefox. Sometimes different version of browser also have different output like the display in IE8 and IE6. To tackle this you can use different css for different browser.
Here’s the code:
<!–[if lte IE 6]>
<style type=”text/css” media=”screen”>
@import “ie.css”;
</style>
<![endif]–>
<style type=”text/css” media=”screen”>
@import “ie.css”;
</style>
<![endif]–>
if lte IE 6 means if browser is lower than equal (lte) IE 6. If you want to use the css specifically to IE 6 then: <!–[if IE 6]>. There are also gte (greater then equal) for browser above or equal a spesific browser. Here’s the summary:
- lte IE 6 -> IE 6 and all version lower
- lt IE 6 -> version below IE 6
- IE 6 -> only IE 6
- gt IE 6 -> version higher IE 6
- gte IE 6 -> IE 6 and all version higher
Download the full code here.









