CSS, Problem and How.
Once this page was very very very, very long and important. As time has passed, some stuff had turned really pointless and was removed. Although, some has still found here.
The fact is, there is no need for any hacks, workarounds nor bodges when a page is coded in a right way. Everything works fine right from scratch in IE6, Firefox, MAC Safari and the whole site is well accessible over Lynx.
There are no problems, never. Sorry.
Some CSS problems and fixes to them.
-
Double space between list items in IE.
- Remove all the white space inbetween the <li></li> tags.
- If it's a link there, add a trailing space inside the anchor tag.
-
text-decoration:underline; doesn't work for FireFox in button element
-
Sample:
- <button style="text-decoration:underline;">Click</button>
-
Solution:
- Remove the doctype
- Float the element
- Apply display:block;
- <span style="text-decoration:underline;">Click</span>
- Apply display:table-cell; This works best. However, table display properties may cause side effects in Firefox.
- Note, the button element is not supported in mobile browsers (WindowsCE, PocketPC and others).
-
Sample:
-
Progressive empty space on sides of a button in IE.
- Apply overflow:visible; and then side paddings.
-
Empty div-s collapse in FF.
- put in  
- Empty div and p behave differently in different browsers. Always use  
-
Empty divs do not collapse in IE.
Double space between lines IE.-
Add an empty comment into the empty div
<div><!-- --></div> or <div><!----></div> - Use script to show/hide the entire element rather than just a content.
-
Add an empty comment into the empty div
-
Long words do not wrap in FF. Wrapping long strings.
- word-wrap:break-word;
-
There is a gap on the top of page in IE6.
-
*{ margin:0px; padding:0px; } - If in style here there was declared border:0, remove it. Border 0 erodes up the upper border of IE6 browser window.
-
-
FF, background is not seen. Reason - div does not expand vertically.
- Add float.
- Adding position:absolute has the same effect.
- overflow:hidden, after that IE will require height:1%
-
margin-auto centering does not work
- Remove float. Remove width:100%
-
Margin left or right does not work.
- If width:100%, change width to fixed or auto. If margin-left, IE6 displays it double; apply display:inline. If possible, better to use paddings for sides.
-
Extra margin space on sides of a floated image or a DIV, IE6.
- Apply display:inline. If possible, use paddings instead of margins.
-
Gap below an image in IE.
- White space characters. Markup syntax. Tag containing img should not end a line nor have a space after it.
- The images got an odd bottom margin that couldn't be removed. The cause was that in strict mode <img /> is an inline element, which means that some space should be reserved for possible descender characters like g, j, or q. Of course an image doesn't have descender characters, so the space was never used, but it still had to be reserved. The solution was to explicitly declare images block level elements - img{display:block}.
-
Vertical distance between floated DIV's in different browsers different.
- Different browsers collapse margins differently. Better to use paddings. Best practice is to organize distances with the padding-bottom.
- Floated divs act differently than non-positioned divs. In the floated divs, the top-margin of the <p> is encompassed in the div. In the not floated divs it isn't. Put a border on the not floated div, or a padding, or float it.
- Use intermediate separator <div style="clear:both;"></div>
- IE6 adds sometimes some extra space below an element if it touches the borders of the surrounding element. Make the inner element by 3 pixels narrower.
-
IE7 margin-bottom does not work. IE6 FF Opera Chrome are OK.
- Hack:
margin-bottom:9px; *padding-bottom:9px; _padding-bottom:0;
- Use padding-bottom instead of margin-bottom.
- Hack:
-
clear:both; how it works, what it does?
- clear:both makes preceeding elements stay above.
-
position:relative; how it works, what it does?
- IE needs this to show float.
-
IE bug-safe comments, Do not leave any spaces within the tags!
- IE does not see it: <!--[if !IE]>Put your commentary in here...<![endif]-->
- IE only sees it: <!--[if IE]>Put your commentary in here...<![endif]-->
-
Disappearing text or (background) images in IE
- These items are still actually there, and if you highlight everything on screen or hit refresh they'll often re-appear. This problem mostly occurs on background images and on text next to a floated element.
- Insert position:relative; for the disappearing element. Sometimes it doesn't work.
- Assign a width to the offending element.
- Advices here are taken from http://www.webcredible.co.uk/user-friendly-resources/css/more-css-tricks.shtml
- While using word-spacing:3em; and need to have some word spaces normal in between, use   instead of just a space.
- Dotted outline around links in FF. To remove apply a{outline:none;} Tabindex will not work for FireFox any more. For buttons css .myButton::-moz-focus-inner; or in the element onFocus="this.blur();"
- Placing a div to overlap another one. FF and IE6. Apply to the div a margin to move it around and position:relative to bring on top of others.
- Layers, position absolute, position relative - as precaution add z-index. This prevents on some cases some other elements climbing on surface of the layer.
-
Layers, in IE6 <select> dropdown combobox climbs on top of the layer.
- No solutions nor hacks whatsoever. Wrong.
- Workaround - do not use layers or popups.
- Workaround - change page layout
- Workaround - do not use <select>
- Workaround - make layer JavasCript dragable + make cursor on mouseover to change arrowscrest.
- IFRAME
.popupLayer{ background:#eee; float:left; height:auto; left:30px; position:absolute; top:50px; width:200px; z-index:2; } .popupIframe{ height:200px; left:30px; position:absolute; top:50px; width:200px; z-index:1; } <iframe class="popupIframe" frameborder="0"></iframe> <div class="popupLayer"> content content content content content </div>
-
Link (anchor tag) does not obey styling, mostly in IE6.
- Use all selectors, and in this order: a:link a:visited a:hover a:active
- Avoid using shorthand (a)
- Convert em to pixel. For non-IE browsers divide by 13. For IE, divide by 13.3333.
2005, 2006, 2007, 2008, 2010.
Web Development - XHTML CSS JavaScript jQuery.