I decided to convert my page over to XHTML from HTML. When I did, it started messing with all sorts of things. I don't really understand why any of these things are happening (although I've figured out how to fix them). I'm not so much concerned with the cure so much as wanting to understand the underlying principles at work here. So, here's the issues:
1) When I converted the page to XHTML, I ended up with the following effect (seen at
http://www.nriyounglife.org/xhtmlindex.htm ). Essentially, it messed with the sizing of things. The width of some of my <div> boxes and font size were increased in IE. However, when tested in Firefox, no issues. Hmmmmm, i thought. Pixels should be pixels should be pixels. So, I took a look at my style sheet to see what might be causing the issue. Padding? Nope. Borders? Nope. Margins? Nope. Then i remembered this bit of code:
html, body, div {
-moz-box-sizing: border-box;
box-sizing: border-box;
- html, body, div {
- -moz-box-sizing: border-box;
- box-sizing: border-box;
I had added that to the HTML based page to make Mozilla and IE browsers use the same box model. Now however, it was causing IE and Mozilla browsers to display them differently. When I removed the code, it caused both Mozilla and IE to display boxes too large. So both browsers were displaying the page wrong in XHTML vs HTML, but at least they were displaying the page the same in both types of browsers. Ok, easy fix, change the width and height settings in the XHTML page. However, I don't understand why the page acted this way in the browsers to begin with. Why would moving from HTML to XHTML cause this issue at all? Why does that bit of code cause Mozilla and IE to render boxes differently in XHTML when it's supposed to make them use the same box model? Why are both Mozilla and IE rendering 172px wider in XHTML than in HTML without the above code? The examples for comparision:
HTML:
http://www.nriyounglife.org (orignal page)
XHTML (with the above CSS entry):
http://www.nriyounglife.org/xhtmlindex.htmXHTML (without the above code, and height and width adjusted):
http://www.nriyounglife.org/xhtmlindexnocode.htmLook at the examples in IE and Mozilla to see the effect I'm describing.
On a related note, the size of the horizontal header and the navigation box at the bottom of the page were unaffected by the change. I figure this is due to the fact they do not have a height specified, and their width is either not specified (header) or set to a relative value (bottom nav box). Their CSS is as follows:
#header {
margin:50px 0px 10px 0px;
padding:17px 0px 0px 0px;
border-style:solid;
border-color:black;
border-width:1px 0px;
background-color: Teal;
font: 20px;
#bottom_nav {
margin: 200px auto 10px;
background: #FFFFFF;
color : #000099;
font-size: 12px;
padding : 4px;
border-color : #48D1CC;
border-style : groove;
border-width : 2px;
width: 70%;
text-align: center;
}
- #header {
- margin:50px 0px 10px 0px;
- padding:17px 0px 0px 0px;
- border-style:solid;
- border-color:black;
- border-width:1px 0px;
- background-color: Teal;
- font: 20px;
- #bottom_nav {
- margin: 200px auto 10px;
- background: #FFFFFF;
- color : #000099;
- font-size: 12px;
- padding : 4px;
- border-color : #48D1CC;
- border-style : groove;
- border-width : 2px;
- width: 70%;
- text-align: center;
- }
2) Converting to XHTML causes the text size to change. The class being used in all versions of the page is as follows:
#main {
padding: 0px 10px 10px 30px;
color: black;
margin: 0px 0px 0px 172px;
font: smaller;
text-align: center;
- #main {
- padding: 0px 10px 10px 30px;
- color: black;
- margin: 0px 0px 0px 172px;
- font: smaller;
- text-align: center;
The text in the .main class is the only text affected by the transition to XHTML, but then again, the text in the .main class is the only text with a relative value vs. an absolute pixel value. Also note the text size difference
between browsers using the same font-size value. In short, HTML vs XHTML is displaying the text size differently. AND, in XHTML, Mozilla and IE are displaying the text size differently given the same font-size value. (In HTML, both mozilla and IE display the text size the same.)
IE seems to display the text one level larger than Mozilla in XHTML. However, the font-size property is still set to "smaller". The fix is easy enough: simply specify a pixel value rather than a relative value for font-size. However, I would like to leave the text size up to the visitor so people can resize the text to suite their needs. Any ideas why the transition to XHTML would mess with how the browsers display the font size, as well as why the browsers display the same CSS property differently in XHTML?
*Phew!* Ok, long friggin' post. I apologize if it was too long, but I wanted to supply enough detail for anyone willing to help to understand the issue completely. Thanks in advance for any insight you all can share! (I need a nap now

)
Mark