Forum Moderators: open
I have some code for an Amazon book ad that has been modified so that it validates. The code does validate and looks perfect in IE at <snip>.
However, it does not center in Firefox and it does not center plus has an odd background in Opera.
I placed the relevant code below.
Can anyone see how I can fix this for Firefox and Opera?
Thanks a lot,
Bob
--
.centerall{
text-align:center;
font-size: 120%;
font-weight: bold;
padding: 0px 0px 0px 0px;
margin: 20px auto 5px auto;
}
<div class="centerall">Amazon Book Sale<br><br>
<!--[if IE]>
<iframe src="http://example.com/" marginwidth="0" marginheight="0" width="120" height="150" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>
<![endif]-->
<object data="http://example.com/" type="text/html"></object>
</div>
</div>
[edited by: encyclo at 1:55 pm (utc) on Aug. 2, 2005]
[edit reason] Examplified and URL removed. Please see forum charter [/edit]
Below is the original code partially generated by Amazon.
This is followed by the new validation fix plus the code preceeding it.
Thanks a lot for looking at this.
Bob
Original:
<div class="centerall"><a href="http://example.com/human-factors-books-user-interface-design1.html" title="Recommended Books">Recommended Books</a><br><br>
<a href="http://www.example.com/human-factors-books-user-interface-design1.html">
<img src="http://example.com/images/books3.gif" alt="Human Factors, User Interface Design, Ergonomics."></a></div>
<br><br>
<div class="centerall">Amazon Book Sale<br><br>
<iframe src="http://rcm.amazon.com/e/cm?" marginwidth="0" marginheight="0" width="120" height="150" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>
</div>
New:
<div class="centerall"><a href="http://example.com/human-factors-books-user-interface-design1.html" title="Recommended Books">Recommended Books</a><br><br>
<a href="http://example.com/human-factors-books-user-interface-design1.html">
<img src="http://example.com/images/books3.gif" alt="Human Factors, User Interface Design,
Ergonomics."></a></div>
<div class="centerall">Amazon Book Sale<br><br>
<!--[if IE]>
<iframe src="http://rcm.amazon.com/e/cm?" marginwidth="0" marginheight="0" width="120" height="150" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>
<![endif]-->
<object data="http://rcm.amazon.com/e/cm?" type="text/html"></object>
</div>
</div>
[edited by: encyclo at 8:20 pm (utc) on Aug. 2, 2005]
[edit reason] tidied up [/edit]
object tag - with IE7 just around the corner, this may well be false. After that, you have an iframe in an IE conditional comment. Again the IE7 problem surfaces as, if IE7 supports object properly, you will get two links rather than one. Finally, the use of the conditional comment in order to make the page validate is a cop-out - you are merely hiding invalid markup from the validator rather than solving the problem. Looking at the two versions, I would strongly recommend the first, unaltered version. Depending on your doctype (transitional would be most appropriate), you can keep the
iframe, remove the border="0" to make it validate or just leave it there and accept one unknown attribute error. The reason why Firefox and Opera weren't displaying the link properly is that they were being served the
object tag only (not the iframe) which does not inherit the style from the surrounding div.
I am going back to the first code. But this will not validate in 4.01 Strict.
I think I am going to live with that code not being valid via W3C. The rest of the page does validate.
Do you see any big issues with that lack of validation from an SEO viewpoint?
Thanks Again,
Bob
Validation is an aid to SEO because it helps you avoid errors that may blank out part (or even all) of your page. But an conscious, intentional choice to use just one bit of non-standard code that is still well-formed will not have any impact on search engine rank.
Can I just simply change my DocType from 4.01 Strict to transitional DTD without messing up the page? If so, what would that form of DOCTYPE look like?
My present one is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Thanks Again,
Bob
But since you are using a full doctype, hymer, that issue should not come up.
I have also noticed an occasional difference in rendering in Firefox between the quirks mode triggered by the partial doctype and the quirks mode triggered by no doctype, but I haven't been able to pin that down yet.
Full doctypes are always safer. :)
Quirks Mode vs. Standards Mode [webmasterworld.com]
I have tried tons of things including changing the DOCTYPE with no success.
I think I am going to have to live with invalid code. I hate to do it because everything has validated for several years. But I do like these additions so I guess I will learn to live with it.
Thanks for all the help,
Bob
I have tried tons of things including changing the DOCTYPE with no success.
Others here have suggested loose and/or strict. You may also try 4.01 transitional as well. However, they all have their own rule sets which you will have to validate against.
Since you mention doctype, you're validating html. Just a suggestion - also validate your css at the w3.org site; though I understand css isn't your primary issue.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
So there are three html 4.01 doctypes -- transitional, frameset, and strict. Loose is just a name they used for the transitional file.