开发者

What are the chronological steps in building a cross browser compatible site? [closed]

开发者 https://www.devze.com 2023-01-27 07:08 出处:网络
Closed. This question is off-topic. It is not currently accepting answers. 开发者_如何学PythonWant to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This question is off-topic. It is not currently accepting answers.
开发者_如何学Python

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 12 years ago.

Improve this question

I am working on my first project that requires me to worry about cross browser compatibility. Since this is my first time doing so, I dont know how to go about completing the project. I am specifically worried about IE. Should I complete my project in a more graceful browser then hack it to work in IE, or should I simultaneously build my program up in both environments?


Design your site to work in standards complaint browsers first. I always start with Firefox, even when developing on my company Intranet (where everyone uses IE). Doing so will let you focus on getting your markup and CSS correct. This is what is most important.

The important thing to note is that you'll want to "future proof" your site, and concentrating on a standards compliant browser will help you do that.

Then, once you're confident your site is looking correct (validators are your friend!), try it out in the versions of IE you want to support. In order to get your layout to look OK in IE, I strongly suggest using different stylesheets for each version of IE, using conditional comments.

Also, you should note that many others have been in the same scenario as yourself, and there is quite a bit of help available. One popular method of forcing IE to behave is the ie-7.js project.

Lastly, be mindful of the top IE bugs, such as:

  • IE6 Box Model Bug
  • IE6 transparent PNG images (I have used this fix in the past)


A few tips:

  1. Code to Standards — Start by ensuring that what you've just developed works in Firefox and Chrome, and then verify it in IE. I'll usually then check it out in Safari. It's always better to make sure your markup/code works in a more standards compliant browser first.
  2. Validate Early, Validate Often — You don't want your design to look perfect in one browser, find out that it's broken in another, discover that to fix the broken layout you needed to correct some invalid HTML/CSS, only to find that now the first browser looks wrong.
  3. Progressive enhancement — will be your friend. Start basic, with simple HTML and simple CSS, and no JavaScript whatsoever. Repeat tips #1 and #2, then move on to more complex styles and layout. Contiue this iterative process until you are happy with the design in all browsers. Only then should you consider JavaScript to polish the site.
  4. Check each browser often — Don't develop the entire website in a single, compliant browser like Firefox, and then decide to "see what's broken" in IE. If you've got a complex, dynamic website, there could be MANY problems in Internet Explorer. Trying to decipher each one when they are compounding on each other is a nightmare.
  5. Reset Stylesheet — As @Eir mentioned in the comments, find a good reset stylesheet. Although, they have fallen out of favor for some people, I find putting every browser on the same footing from the start helps tremendously.
  6. Use a Framework — I find CSS Frameworks to be excessive, but some people swear by them, so to each his own. On the other hand, as soon as you have made it to the JavaScript phase of development, I highly recommended using jQuery or MooTools. They are very focused on circumventing cross-browser inconsistencies.
  7. Let JSLint hurt your feelings — Even when using a JavaScript framework, there are certain standards of coding to which JSLint will help you conform. Some of the options are a bit overly strict, but I promise that if you clean your scripts through this tool often enough during development, you will almost never encounter those strange times when everything seems to work in all browsers except IE.

And some great tools! Everything in the above list you should consider mandatory practice. The following can spice it up for you in a pinch, but is optional:

  1. CSS Browser Selector — it is rare that you will need this, but if all else fails, it's way cooler than using a separate stylesheet just for one browser (I despise conditional comments). It basically adds classes to your <html> tag, so you can do things like the following in your main stylesheet: .ie7 #header {/*stylese here for IE7 only*/}. It supports a lot of browsers on many operating systems. And it's fast.
  2. Browsershots — Nothing beats the real thing, but if you can't install a suite of browsers, this and other tools like it can help.
  3. IE6 CSS Fixer — I outright refuse to debug my designs in IE6. I coerced my company (via many chagrin-filled meetings with IT and management) to drop support for it (thank god). It's just counter-productive to waste so much time forcing this pile-of-ahem... Anyway, if you aren't like me and need to support IE6, this tool can help.


Also you should focus on resetting css like this


OOoooo, good question:

here's my take:

  1. Decide which browsers you are supporting. I suggest IE 7 + 8, FF, Chrome and Safari as in order of importance. (only support IE6 if you absolutely have to!). It helps if you know your userbase here.
  2. Use a css reset. Different browsers have different default styles. a css reset gives you a consistent base.
  3. Keep your markup as simple as possible. Follow Standards (and see progressive enhancement on Stephen's answer).
  4. Test every step of the way on your target browsers. That way you can correct problems right away. http://crossbrowsertesting.com/ is the best resource for this, but there are free ones for screenshots as well.
  5. Avoid Hacks as much as possible. Most cross-browser issues these days can be solved without resorting to hacks.
  6. Ask questions here when you get stuck. If this is your first project dealing with browsers, you will get bewildered by inconsistencies. We all face these issues, and are glad to help.
  7. Be ok with the fact that webpages are not going to look exactly the same in all browsers. (once again, see progressive enhancement).

Good luck coding!


I develop for Firefox first, and then work out the IE buggery. Rarely do I "hack" it, rather find something that works in both, or at worst use IE conditional comments. Just one coder's preference. Always a good idea to test with Safari, too.

Two big advantages of Firefox are: the Error Console, and the Firebug plugin.


there is alot of greate tools that makes life alot easier for you there is for example a css framework called blueprint you could use, it has already everything set for every specific browser so that you get the same outcome in all browsers. And using jquery as your javascript framework does add an extra insurance that you'll have it working in most browser.

but remeber there is no such thing as 100% cross browser compatibility for all the browsers and all the versions in world.


In theory would be best to develop for all browsers at once, always testing for every browser...

Realistically, that rarely happens... I typically develop/test with firefox. when I introduce complex javascript or css, I check in ie... this tool is incredibly handy for checking all versions at once... google ie tester.

By checking all browsers at regular intervals, and when you make complex changes, you ensure that major features are compatable :)

Also, ensuring that all of your code is valid is not only good practice, but helps identify cross browser issues.. google w3schools validator :)

Using javascript libraries such as jquery also aid in cross browser compatability, and some even come with css libraries as well. These libraries are purpose built for quick, reliable features that are typically cross browser guaranteed.

Finally, before launching, use launchlist to check that all works: http://lite.launchlist.net/

Hope all that makes sense and helps with your first project :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号