iframes not valid in XHTML Strict

Ryan Durrant picture Ryan Durrant · Nov 25, 2011 · Viewed 8.2k times · Source

I am building a website with a Google Map, which by default generates this code:

<iframe width="550" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Amber,+115+Portswood+Road,+Southampton,+SO17+2FX,+United+Kingdom&amp;aq=0&amp;sll=50.923556,-1.394663&amp;sspn=0.006709,0.01929&amp;vpsrc=6&amp;ie=UTF8&amp;hq=Amber,&amp;hnear=115+Portswood+Rd,+Southampton+SO17+2,+United+Kingdom&amp;t=m&amp;ll=50.923178,-1.393676&amp;spn=0.012985,0.027466&amp;z=15&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co.uk/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Amber,+115+Portswood+Road,+Southampton,+SO17+2FX,+United+Kingdom&amp;aq=0&amp;sll=50.923556,-1.394663&amp;sspn=0.006709,0.01929&amp;vpsrc=6&amp;ie=UTF8&amp;hq=Amber,&amp;hnear=115+Portswood+Rd,+Southampton+SO17+2,+United+Kingdom&amp;t=m&amp;ll=50.923178,-1.393676&amp;spn=0.012985,0.027466&amp;z=15" style="color:#0000FF;text-align:left">View Larger Map</a></small>

Now this throws an error when checked for XHTML Strict, as it is Frames which are outdated, but what should I use instead?

Thanks for the help

Answer

BoltClock picture BoltClock · Nov 25, 2011

If you must have a Maps iframe on your page, the easiest solution is to change your doctype to XHTML 1.0 Transitional instead, which permits the use of iframes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

However if you start to see any differences in page rendering (see standards mode vs almost standards mode), and you're more concerned about how your site looks in web browsers than validating your markup, just keep the XHTML 1.0 Strict doctype. Browsers won't error out simply because a page is invalid XHTML; they'll handle your iframe just fine either way.