45

For school I have to make a website that must use frames. I complained to my teacher without success.

I want to use HTML5 but seems frames are deprecated. Am I required to use XHTML, HTML 4 or is there some work-around that makes my pages valid HTML5 with use of frames?

user4157124
  • 2,809
  • 13
  • 27
  • 42
  • 53
    Part of the learning process at school is learning that (a) profs aren't infallible (b) that sometimes there are requirements that are stupid, dated, archaic, and are _still_ requirements. :) Best of luck. :) – sarnold Jan 30 '11 at 22:39
  • 17
    This teacher of yours shouldn't be teaching web development if this is the extent of his knowledge. – You Jan 30 '11 at 22:46
  • 2
    I had to build a frame based website for school in 2004-2005. Even then they were laughably out of date. Good to know it's still going strong! – Chris Harrison Aug 01 '12 at 08:18
  • 3
    Frames are still widely used in e-learning, with some content connecting via SCORM, persisting state using a frameset. Hopefully that'll go away soon, but in the meantime your teacher appears to have provided you with a potential job in the education industry! – danjah Oct 30 '13 at 00:56
  • 4
    @Valen, because that is well supported http://caniuse.com/#feat=iframe-seamless – nat Sep 25 '14 at 14:37

5 Answers5

42

I know your class is over, but in professional coding, let this be a lesson:

  • "Deprecated" means "avoid use; it's going to be removed in the future"
  • Deprecated things still work - just don't expect support or future-proofing
  • If the requirement requires it, and you can't negotiate it away, just use the deprecated construct.
    • If you're really concerned, develop the alternative implementation on the side and keep it ready for the inevitable failure
    • Charge for the extra work now. By requesting a deprecated feature, they are asking you to double the work. You're going to see it again anyway, so might as well front-load it.
    • When the failure happens, let the interested party know that this was what you feared; that you prepared for it, but it'll take some time
    • Deploy your solution as quickly as you can (there will be bugs)
    • Gain rep for preventing excessive downtime.
Fordi
  • 2,798
  • 25
  • 20
28

Now, there are plenty of example of me answering questions with essays on why following validation rules are important. I've also said that sometimes you just have to be a rebel and break the rules, and document the reasons.

You can see in this example that framesets do work in HTML5 still. I had to download the code and add an HTML5 doctype at the top, however. But the frameset element was still recognized, and the desired result was achieved.

Therefore, knowing that using framesets is completely absurd, and knowing that you have to use this as dictated by your professor/teacher, you could just deal with the single validation error in the W3C validator and use both the HTML5 video element as well as the deprecated frameset element.

<!DOCTYPE html>
<html>
    <head>
    </head>
    <!-- frameset is deprecated in html5, but it still works. -->
    <frameset framespacing="0" rows="150,*" frameborder="0" noresize>
        <frame name="top" src="http://www.npscripts.com/framer/demo-top.html" target="top">
        <frame name="main" src="http://www.google.com" target="main">
    </frameset>
</html>

Keep in mind that if it's a project for school, it's most likely not going to be something that will be around in a year or two once the browser vendors remove frameset support for HTML5 completely. Just know that you are right and just do what your teacher/professor asks just to get the grade :)

UPDATE:

The toplevel parent doc uses XHTML and the frame uses HTML5. The validator did not complain about the frameset being illegal, and it didn't complain about the video element.

index.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html>
    <head>
    </head>
    <frameset framespacing="0" rows="150,*" frameborder="0" noresize>
        <frame name="top" src="http://www.npscripts.com/framer/demo-top.html" target="top">
        <frame name="main" src="video.html" target="main">
    </frameset>
</html>

video.html:

<!doctype html>
<html>
    <head>
    </head>
    <body>
        <div id="player-container">
            <div class="arrow"></div>
            <div class="player">

                <video id="vid1" width="480" height="267" 
                    poster="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb480.jpg"
                    durationHint="33" controls>
                    <source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb_trailer_iphone.m4v" />

                    <source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb400p.ogv" />

                </video>

        </div>
    </body>
</html>
jamesmortensen
  • 33,636
  • 11
  • 99
  • 120
  • Is it possible to define the video element and its attributes in a second DOCTYPE and use XHTML with the video tag? –  Jan 30 '11 at 22:56
  • @Radek - I updated my answer to show that the parent document can use a different doctype than the child frames. Great question! You should just bite the bullet and do what your professor/teacher is asking you to do, and know that you're going to be a great asset to your future employers! Nice job! – jamesmortensen Jan 30 '11 at 23:13
  • @jmort253 stupid me. Of course! I can just use XHTML for the parent page and HTML5 for the frames. :) –  Jan 30 '11 at 23:15
  • @RadekS You can use whatever doctype you want - the determining factor is whether the browser supports `video` not the document type. None of Firefox, Chrome or Opera care, they'll play the videos whatever. – robertc Jan 31 '11 at 02:39
  • 2
    @robertc I know, but I want it to validate. :) –  Feb 03 '11 at 18:54
  • @jmort253: It's just that, that frames don't work in e.g. Firefox version 13.0.1, at least not without an add-on. I'm sorry to hear, WTP, that you can't get your teacher to not use frames :-((( Hope you can find a way to make the project good anyway :) – Lasse Bunk Jul 03 '12 at 15:35
  • @LasseBunk - This all happened over a year ago. ;) Maybe he did get through to his teacher by showing him this question. – jamesmortensen Jul 04 '12 at 00:56
  • @jmort253: Ooops, I didn't notice that :-) Yeah, we must hope that he got his teacher to require otherwise :) Have a good day :) /Lasse – Lasse Bunk Jul 04 '12 at 07:47
  • @pattyd - Fixed. It looks like any site that has the X-Frame-Options header set to SAMEORIGIN can no longer be included in a frame or iframe, so I replaced it with duckduckgo. – jamesmortensen Jul 07 '13 at 20:59
  • @jmort253 Cool, thanks! BTW, what is X-Frame-Options? Do I have to use that for frames support in HTML5 or something? – pattyd Jul 08 '13 at 00:50
  • @pattyd - No. This is a header returned with the HTTPResponse that tells user-agents (i.e. your browser) not to allow the website to be embedded in iframes or frameset elements. Sites like Google, Stack Overflow, and Yahoo do this to prevent other websites from pretending to be them. Give it a try yourself. Try to put this on your website: ``, then do the same with http://duckduckgo.com. Good luck! – jamesmortensen Jul 08 '13 at 01:38
4

Maybe some AJAX page content injection could be used as an alternative, though I still can't get around why your teacher would refuse to rid the website of frames.

Additionally, is there any specific reason you personally want to us HTML5?

But if not, I believe <iframe>s are still around.

jerluc
  • 4,186
  • 2
  • 25
  • 44
  • I want to use HTML5 especially for the video tag. My teacher isn't very experienced with web development either; he didn't even know about CSS until I showed him. Isn't it possible to use a custom DOCTYPE, perhaps? –  Jan 30 '11 at 22:40
  • Given HTML5's current and very slim support (http://diveintohtml5.org/video.html) amongst today's browsers, I would be hesitant to use such a feature for the time being. And unless you are able to determine exactly which browsers and browser versions your users are using, you'll be stuck without also creating some sort of fall-back. – jerluc Jan 30 '11 at 22:45
2

You'll have to resort to XHTML or HTML 4.01 for this. Although iframe is still there in HTML5, its use is not recommended for embedding content meant for the user.

And be sure to tell your teacher that frames haven't been state-of-the-art since the late nineties. They have no place in any kind of education at all, except possibly for historical reasons.

You
  • 22,800
  • 3
  • 51
  • 64
2

Frames were not deprecated in HTML5, but were deprecated in XHTML 1.1 Strict and 2.0, but remained in XHTML Transitional and returned in HTML5. Also here is an interesting article on using CSS to mimic frames without frames. I just tested it in IE 8, FF 3, Opera 11, Safari 5, Chrome 8. I love frames, but they do have their problems, particularly with search engines, bookmarks and printing and with CSS you can create print or display only content. I'm hoping to upgrade Alex's XHTML/CSS frame without frames solution to HTML5/CSS3.

demongolem
  • 9,474
  • 36
  • 90
  • 105
Keith
  • 29
  • 1
  • 3
    Frames are listed as "entirely obsolete" and among those (non-conforming) features of HTML that "must not be used by authors" at http://www.w3.org/TR/html5/obsolete.html#non-conforming-features even if processing requirements are listed at http://www.w3.org/TR/html5/obsolete.html#frames – Brett Zamir Mar 02 '14 at 23:28
  • 1
    @BrettZamir it is one of the largest mistakes ever made by community standards to count frames as obsolete. They provide features still not available in iframe which would be very beneficial to web apps of today if properly exploited. – That Realty Programmer Guy Nov 10 '21 at 22:33
  • I agree, but is worth noting in case browsers do act in such a manner as to entirely remove their support. – Brett Zamir Nov 11 '21 at 02:05