Click to Play

Time to Get Serious about Social...
According to Chris Brogan, the President of New Marketing Labs, we have all been playing around with social media for far too long. It is his hope that users...

Recent Articles

Are XML Sitemaps Important?
XML Sitemaps, (also known as Google Sitemaps) are accepted by all three major search engines as a source of information about your site. Google Webmaster Tools even has a spot where you can tell Google where...

Keeping Your Site Running Smoothly With High Traffic
A bloggers dream is to get noticed. That could be in the form of a post getting re-tweeted hundreds of times, hitting the homepage of Digg, shared a lot on...

Debugging Your Site With Googlebot View
Have you ever thought that it would be helpful and “really cool” to be able to transform yourself into a bot? Well, maybe not. But the next best thing for us...

Debugging Flex Builder Remoting Calls
Imagine the times when Flash Builder (Gumbo) was still in beta, times when the Network Monitor was still only a twinkle in the corner of a Flex engineer's eye.

Collecting Analytics Data On Your 404 Error Page
404 errors are a fact of life on the internet. 404 error is a message returned by a server in response to a request for a page that does not exist on the server (http...

Building Links Holistically For Web 2.0 Standards
Link building has changed, specifically around the concept of Web 2.0. Here is the definition from SEW: Web 2.0: A term that refers to a supposed second generation of Internet-based services. These usually include tools...


11.06.09

How To Add iFrames To Your XHTML 1.0

By Mads Kristensen

Recently I had to use iframes on a website conforming to XHTML 1.0 Strict. As you might know, the XHTML 1.0 Strict doctype doesn’t allow the use of iframes. The XHTML 1.0 Transitional doctype on the other hand, does allow you to use iframes, but I don’t like to use that doctype. The reason is, as the name implies, that it’s a doctype meant for make the transition from HTML into XHTML – a sort of a temporary solution.

When building new websites I like to use a strict doctype because it doesn’t allow for many of the style and behavioral tags that is much better placed in stylesheets and JavaScript.

What’s needed is a doctype that conforms to XHTML 1.0 Strict which also allows for iframes.

A solution

What I came up with was very simple, but may be considered a hack by some. Basically, I took the doctype declaration (DTD) of XHTML 1.0 Strict and added support for iframes. I found how iframes was supported in the transitional DTD and copied it to the Strict DTD. It allows for some attributes like width and height that the Strict DTD doesn’t, so I removed those and then added support for the allowtransparency attribute.

So to make iframes work on your own invalid XHTML 1.0 Strict page, just replace the doctype at the top of your pages with this new one:



I suggest you download and host the DTD on your own server instead of using mine in case I forget to pay my hosting fee.

Check out the demo of XHTML 1.0 Strict with Iframe


A hack?

Some might say it’s a hack because by using this DTD the page is no longer XHTML 1.0 Strict. That is correct. It is now something new and different, but completely identical to XHTML 1.0 Strict with support for iframes. So it’s XHTML 1.0 Strict with Iframe.

XHTML have build in support for custom DTDs and thus this is completely supported and valid XHTML. If you don’t like using other doctypes than the few main ones created by the W3C then I have to ask why? What does it give you, your users or the quality of the page that this new one doesn’t?

In my book, it comes down to using a doctype that is based on known standards (XHTML 1.0 Strict in this case) so it still make sense to other devs when they read the markup. It’s also important that the DTD is strict (yep, this DTD is still strict), but most of all it’s important that the markup conforms correctly to the DTD so the entire page is valid. Remember, when using custom DTDs your page is still valid XHTML.

Note

I tried using XHTML 1.1 modules to build the DTD, but it never worked out for me. I got to the point where the iframe tag was valid, but not allowed in any other tags including body. I couldn’t seem to find a way to get full support for it. If you know how, please let me know.

Comments

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.
About DevWebPro
DevWebPro is for professional developers ... those who build and manage applications and sophisticated websites. With over 300,000 subscribers, DevWebPro delivers via news and expert advice New Strategies In Development.





DevWebPro is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagementnews.com






-- DevWebPro is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
 © 2009 iEntry Inc.  All Rights Reserved  Privacy Policy  Legal 



DevWebPro Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact