45

For school I must make a website and it must use those crappy old damn fml frames. I've already complained about this to my teacher without any success :(

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

  • 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

6 Answers6

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,640
  • 23
  • 19
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>
jmort253
  • 33,123
  • 11
  • 95
  • 117
  • 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! – jmort253 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. – jmort253 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. – jmort253 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! – jmort253 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,038
  • 2
  • 24
  • 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
  • 21,633
  • 3
  • 49
  • 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,148
  • 36
  • 86
  • 104
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
0

I have used frames at my continuing education commercial site for over 15 years. Frames allow the navigation frame to load material into the main frame using the target feature while leaving the navigator frame untouched. Furthermore, Perl scripts operate quite well from a frame form returning the output to the same frame. I love frames and will continue using them. CSS is far too complicated for practical use. I have had no problems using frames with HTML5 with IE, Safari, Chrome, or Firefox.

  • 8
    I'm not against using frames where they are useful, but I disagree with "CSS is far too complicated for practical use". CSS is powerful and worth learning. Also, CSS and frames are not mutually exclusive (or inclusive). In fact, they are not related at all in this context. You could achieve the functionality you describe with or without frames and with or without CSS. – showdev Mar 13 '15 at 20:34
  • 3
    Maybe you should continue your education in web development and learn some modern technologies? I can't think of a single valid use case for frame-based websites. Terrible user experience, poor SEO, and an obsolete hack to problems that was solved years ago. Limited use of iframes only, never use a frameset. – Alexander O'Mara Mar 15 '15 at 02:47
  • 4
    This has to be a troll. – Marcus McLean Mar 16 '15 at 14:23
  • This is a valid point if you mean "achieving the same effect as frames is quite difficult in CSS". I would say it's not only CSS, you need more than that. But there's a baby elephant somewhere in the corner: why would anyone not consider two iframes in a parent document? It's exactly what frames do, except for the adjustable separator. (Which is tricky but doable). So I think frames didn't go anywhere - it's a good thing to have two documents on a page. And yes you can do it. Only the parent is different; the child documents should not even be aware of what's happening. – dkellner Aug 31 '19 at 10:36