Positioning in IE - html

While creating a site I've noticed that IE places things slightly differently from Chrome or Firefox.
I mean I have one thing below another and in Firefox and chrome there is a 15px space between them. But in Ie its more like 25px. I keep reading about designing for all browsers. But how do I do that because If I make it look right in one browser it will always be different in another.
Do I move it to suit IE? Because then it will look wrong in Chrome.

You can keep tweaking your code untill it looks good for all browsers
Another option would be to have a seperate style sheet for IE. this would allow you to design for IE as well but you would need to keep in mind that you have 2 style sheets and would need to work on both when you make changes to your site

First of all welcome to web development!
What you can do is load a "Conditional stylesheet" which will only load in IE,
Chris Coyier from CSS-Tricks does a great job of explaining this so take a look here
http://css-tricks.com/how-to-create-an-ie-only-stylesheet/
That should help you out, but it is a tricky task getting everything cross browser compliant but not impossible, just keep at it and you'll get there.
Good luck man!

Try using a css reset first in your style sheet. The reset will customize all the attributes which you can define as per your needs. The main purpose of the css reset is acheiving complete control of all the attributes and defining a generic behaviour for the browsers. Tweaks will help, but in long run, a balanced solution has to be implemented for major things to work out well.
Below are some popular CSS Resets that you can use.
Eric Mayer Reset
Yahoo Reset
Hope this helps.

Related

My site on Internet Explorer 8: What a mess

I have a Windows 7 with service pack 1, and Internet Explorer 10. And I have my site, http://www.gfcf14greendream.com/ . It looks great on Chrome, Firefox and Safari, but not in Internet Explorer. For starters, I wanted to test how my site looks using IETester, and it's a mess (please compare by clicking the link above):
The thing is, I think that maybe the issue could be that IE8 doesn't load well from <object> tags, is that it? I use three object tags to load the three white parts: header, vertical menu, and "site log" (you can see them here: http://www.gfcf14greendream.com/header.html , http://www.gfcf14greendream.com/verticalmenu.html , http://www.gfcf14greendream.com/thesitelog.html)
To load those three sites, I use the following code:
This one for the header, <object type="text/html" data="http://www.gfcf14greendream.com/header.html" width="100%" height=185></object>
This one for the menu, <object type="text/html" data="http://www.gfcf14greendream.com/verticalmenu.html" height=484 width=100%></object>
And this one for the log, <center><object type="text/html" data="http://www.gfcf14greendream.com/thesitelog.html" height=600 width="90%"></object></center>
Please let me know if anyone has any ideas concerning this "mess". Thank you!!
This isn't a real answer (It's a quick and careless answer at best, so don't take it too seriously)
But I just thought I'd mention that the the W3C markup validator might be useful to you if you don't already know about it.. It catches bad markup practices or errors on your page and can give you more information on how to fix them. At the time of writing, your front page alone has 10 errors and 3 warnings on it. Maybe this could point you in the right direction?
upon a quick skim of your page you don't seem to be utilising CSS properly. That is to say, that I see you are using css but you have elements on your page (use of <center> HTML tags, inline styling and things like that) that go against the grain of why CSS was invented.
If you haven't already seen the CSS zen garden, take a quick read/look at it. It should set you right on why we use CSS instead of tables and alignment tags.
(People sometimes don't get this immediately, but , click the links on the right in the zen garden. The same HTML and page content are completely restyled using one html file and seperate CSS sheets)
Good luck!
Edit:
Oh, I almost forgot to mention that internet explorer 8 doesn't have much (if at all) HTML5 compatibility. If you want to develop websites and web apps in HTML5 you'll be hard pressed to serve your I.E 8 visitors and may end up spending more time fixing bugs than you are developing the content.
Some developers are already boycotting I.E 8 entirely to usher in the new era of the web with HTML5 and CSS 3. There are a few js compatibility libraries out there (like excanvas for the new <canvas> element for example) but they don't work flawlessly and you will eventually have to draw the line somewhere. (lol. canvas.. draw line.. get it?) That being said, i did find this article and this may be useful to you:
turn-on-html5-in-ie8-or-lower
Not every website requires HTML5 and it's new technologies, but if you plan on using it for things like the <canvas> tag, Id suggest (from my own personal opinion) you forget about I.E 8 and concentrate on browsers that utilise it.
Remember that you can make checks in your HTML to see what browser version your visitor is using.
You can see if they are using an incompatible browser, and if so, you can then alert them that their software is out of date and suggest to them alternatives (such as chrome or firefox)
There's a bunch of tutorials on-line about this, here's the first decent looking one I found in a quick Google search this article covers using this technique for seperate CSS sheets but there are others that talk about the problem I mentioned in more depth and I'm sure you can probably figure out how to do it anyway once you read the article.
Either way, I'd say you've got a little bit of reading ahead of you to understand why your humble website does not work in an increasingly obsolete browser.
Again, good luck to you in your future endeavours.
Edit was too harsh:
Having looked a the site I would start by suggesting in future you think about design from a users perspective - the colour scheme you're using isn't very friendly on the eye, the red text against the green is particular troublesome to people with red/green color blindness, you also should consider how your content is presented.
End Edit:
However, regarding your IE issues.
First things first, with any work is getting a firm plan of what you hope to achieve and setting a good groundwork before starting. With HTML that means leveling the playing field with regard to browser quirks, and to achieve that, you use a reset css file.
This ensures that all browsers (as close as possible) behave in more or less the same way, regarding padding, spacing, line heights etc, and can go along way to prevent these sort of problems from happening, and allow you to achieve consitancy.
There's more info at the link below.
http://meyerweb.com/eric/tools/css/reset/
Secondly your HTML version - your declaring HTML5 but then use HTML4 values and attributes - basically your site (as pointed out above) is not valid markup.

Is there an easy way to generate a CSS file that is compatible with all (or most) browsers?

I am in a collaborative work of generating a website for disabled people, mostly will run on limited number of educational centers-offices that will donate tablets and old-notebooks to attendants. I am telling you this because i want to give you an idea about the possible users and different OS and browsers.
I want to generate CSS code that will be compatible with all possible browsers; older and newer browsers..
I am writing from scratch and i build it by visiting http://browsershots.org/ each time to see if there is any compatibility issues, but it takes time. Also i use http://jigsaw.w3.org/css-validator/ but again too many manual work..
What i would like know is: do you happen to know any tool that you feed your CSS file that is compatible with, say IE at the beginning, and hands you the extended version of the CSS file that covers many of the compatibility issues?
Any help is greatly appreciated..
In simple words there is no easy way to generate one CSS for all browsers.
For details, It highly depends a lot of over how extensively are you using the CSS, what version of CSS is that etc plus there are many places where different browser renders same CSS property in different ways, so its not really simple enough for all the situations.
But, for a little help, with the time passing there are different tools and scripts that can make your task of achieving CSS compatibility for all browser easier, I would recommend you go through the following tools they can be useful to you while trying to maintain your CSS.
15+ techniques and tools for cross browser CSS coding
Some CSS-preprocessor/helpers to help you in maintaining your CSS throughout:
Less: The dynamic stylesheet language.
Sass makes CSS fun again.
Compass is an open-source CSS Authoring Framework.
I'm not sure such a tool exists. That said, there are some advices to write cross-browser CSS:
Use a reset stylesheet (e.g. http://meyerweb.com/eric/tools/css/reset/);
Use IE conditionnal comments such as <!--[if IE]><![endif]-->;
Practice a continuous coding: open few browsers (e.g. IE, FF, Chrome) and check the run-of-river display they provide;
Use IETester to check IE5.5+ rendering, depending of the IE versions you want to cover;
Use absolute positions and specify widths and heights (especially when using floating elements) whenever you can;
If you want to try CSS3, use PIE;
Try to write pure, simple CSS, avoid exotic layouts.
Netbeans IDE has a feature which helps you to construct CSS from simple tick boxes and drop downs. I haven't confirmed the validity against W3 yet though, but the code generated looks good.
Also a useful resource to check use is http://www.w3schools.com/cssref/default.asp. It does take time to reference the properties you wish to use, but it is always worth confirming their compatibly if your going to experiment with layouts, and a must if using CSS3.
W3 Schools gives a clear indication of which browser supports a stated property. See example image below which is shows the compatibility for box-pack.

Minimal CSS for Internet Explorer (7,8,9)

This is the first time I will be implementing for IE9 and since I've installed Windows 7 which came with IE9, every site I have checked that we've built has some issues in IE9.
What I'd like to know is:
Is there a way to absolutely use minimal CSS to sort out all three browsers or will there always be the need for conditional css for the different IE versions?
Is there a specific doctype I should be using that will sort a lot of this out?
Many thanks,
James
It depends on your needs and requirements. My personal website has exactly one style sheet that works across all major webbrowsers. But my personal website is very simple.
Nope. But please, do pick and include a doctype. This article explains how it will effect rendering in IE.
1) 8 and 9 are pretty similar, 7 has a few things missing. Yes, you will always have to take into account all 3. This may be by removing any problems with the browser BEFORE you style with a CSS reset, although this doesn't solve everything, or use conditionals.
2) Not really, the browser will automatically select one if one is not defined. Either way, it won't change how the page renders.
The best way to minimise the problems is to use an initial CSS Reset file to bring as many of the differences back into line as possible.
Also, consider using a well established CSS framework such as 960 Grid or Blueprint. This will at least mean you are adopting a well used / contributed to framework which will minimise the cross browser inconsistencies that you are unaware of.
The CSS reset idea is a good one if you are just starting out but will hide differences between browsers that may confuse you later.
The best doctype to use now is <!DOCTYPE html> which puts all browsers into standards mode.

Page looks good in most browsers except in IE7...why

The following page looks good in Firefox, Safari, Chrome, IE6 and IE8... but it looks bad in IE7. I don't have IE7 but I need to fix this issue because someone seen it in IE7 and it looks bad. Does anyone has any idea why this page renders different in IE7?...and what is the solution to make it display correctly?
http://www.aetna.com/2009annualreport/mainBoard.html
Problem:
When you click on the "Board of Directors" or "Management Team" link and the listing table panel opens up, the far right third of the panel is getting cut off. Also some information appears to be missing in the cells.
Thanks,
Attila
Yes.. use a css-reset
But also... use the validator.
http://validator.w3.org/
I used the validator and found this:
Polo Ralph Lauren Corporation</p></li>
Notice the misplaced li ?
Also add this to #boardPanel
{ width: 990px; }
This problem disappears when I remove overflow: hidden; from the .boardSlider class.
Look like another hasLayout bug.
All browsers render web pages differently. There is no one solution that will always make everything look exactly the same across all browsers. The best option is to start with a browser such as firefox or safari when you are testing and then tweak your css for internet explorer as you go along. One common technique is to use a CSS reset to try to abstract differences between browsers.
If you don't have IE7 on your machine you can test in it using http://spoon.net/browsers to see what your page will look like or see this question for more suggestions.
Check out Adobe Browser Lab. Very cool and very efficient and the best part is it's free (not anymore thanks for the headsup). It not only has various browser options but also OS options.
HTH
Just a thought - why not use DIVS and floats - you should never really use tables for layout purposes (particularly as it's 2010). Especially dynamically changing layouts. Tables are cross-browser hell, particularly when expanding / contracting using JavaScript and, from a purist's point of view, you are not displaying tabular data, so why use a table?

How to make sure the CSS work fine with all browsers without eye testing on each browser?

Making CSS for one website to support for all browsers in different version is really difficult. Especially, it needs to have different browsers set up.
I just wonder is it possible to test the CSS and make sure it works with all browsers without open each browser and manually check the layout?
or
Is there any quick or standard way to do this?
Use a CSS Reset stylesheet
Use good CSS frameworks (blueprint, boilerplate etc.)
This is not possible.
A few important things to get you started on your journey:
Use a DOCTYPE or you'll throw browsers into quirks mode.
Reset your CSS so you can apply the styles you want to elements.
Use a Javascript library - the popular one around these parts is jQuery, and it is the one I personally recommend. However, it doesn't really matter which one you go with as long as you use one. A lot of smart guys have put a lot of hours into taking care of all the incompatibilities between browsers. Trying to do a lot of dynamic stuff on your website with pure Javascript is bordering on masochistic.
Once I started doing these things, making my site work the same across browsers got a whole lot easier. No matter what, however, you will have to check them all. There's just no way around that.
There's not really a standard way to do this - it's just the nature of the beast; however, Adobe is currently working on BrowserLabs which should help to solve this exact issue.
It would be nice if there was an automated tool to do this. Unfortunately, the only way to tell if something is visually correct is by looking at it.
There are services (such as BrowserShots) that will visit your site on different browsers and take a screen capture for you and then let you download a file containing all of the renderings of your site, but you would still have to verify them manually.
Computers aren't very good at telling if something looks "nice" automatically or else all browsers would always do exactly what you mean (make stuff pretty).
If you're looking to test out JavaScript, you could try a test suite called Selenium.
In the future you could look into a project started by the creator of jQuery called Test Swarm, which looks promising, but is still in testing stages and may not ever be released due to bandwidth costs. It would allow you to test your JavaScript on every major browser on every major platform using a distributed system. This is still very much a pipe dream however because of some of the complications involved with such a system.
You cant really get round human UI testing. I agree with the others that you should be standards compliant and reset css.
Rarely will you get HTML + CSS to render exactly the same across all browsers and on all platforms, purely due to the idiosyncrasies of each browsers. But, just because there are slight rendering differences, doesn't necessarily mean something is wrong, this is a good reason for human UI testing.
Make sure you declare a doc-type.
Use reset css.
Avoid using width and padding(left and right) on the same element where you can.
clean the code in HTML and css.
Don't use margin left and right when floating elements and use its parent overflow:hidden, display:inline and height: 1% if the parent does not already have a height.
Don't give an element both margin-top or margin-bottom but only margin-top or
margin-bottom. Because margins of adjacent elements collapse into one another,
making the positioning somewhat unpredictable for novices.
Don't rely on z-index unless your scripting needs it.
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>
<![endif]-->
<script type="text/javascript" src="js/html5shiv.js" ></script>
<script type="text/javascript" src="js/html5.js" ></script>
you can download shiv.js form this browser compact
browser compatibility testing tools:
http://crossbrowsertesting.com/
http://browsershots.org/
http://www.browsercam.com/
http://caniuse.com
http://www.findmebyip.com/litmus/
I suggest using one of the ready to use Front-End Development Frameworks like Twitter Bootstrap or Foundation. Both are well documented and pretested , so this will reduce the pain of testing.
They contain :
CSS Reset/Normalize
Ready to use components (Buttons, Form Elements, Menus ... etc ).
Grid Layout (Which is the perfect way to arrange stuff in your web page).
JavaScript.
Of course you will need to do your own testing as you tweak those frameworks, in addition to all tools mentioned above, i suggest IE-Tester , really awesome debugging tool for IE (Which is the source of the pain).
Finally, And for the sake of perfection , it's better to test your website (as possible as you can) cross all browsers and devices specially if your doing responsive design.
You have no choice but to do it! That's why web designers salary's is usually high x-)