How to create valid HTML5 using frames?
Asked Answered
P

5

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?

Phosphorescent answered 30/1, 2011 at 22:34 Comment(6)
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. :)Helgeson
This teacher of yours shouldn't be teaching web development if this is the extent of his knowledge.Marti
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!Buzzer
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!Copolymerize
<iframe seamless="seamless">Tellurize
@Valen, because that is well supported caniuse.com/#feat=iframe-seamlessDoughty
L
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>
Labarum answered 30/1, 2011 at 22:54 Comment(11)
Is it possible to define the video element and its attributes in a second DOCTYPE and use XHTML with the video tag?Phosphorescent
@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!Labarum
@jmort253 stupid me. Of course! I can just use XHTML for the parent page and HTML5 for the frames. :)Phosphorescent
@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.Nigro
@Nigro I know, but I want it to validate. :)Phosphorescent
@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 :)Varien
@LasseBunk - This all happened over a year ago. ;) Maybe he did get through to his teacher by showing him this question.Labarum
@jmort253: Ooops, I didn't notice that :-) Yeah, we must hope that he got his teacher to require otherwise :) Have a good day :) /LasseVarien
@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.Labarum
@jmort253 Cool, thanks! BTW, what is X-Frame-Options? Do I have to use that for frames support in HTML5 or something?Cassaundracassava
@Cassaundracassava - 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: <iframe src="http://stackoverflow.com" width="800" height="1200" />, then do the same with duckduckgo.com. Good luck!Labarum
D
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.
Donau answered 29/9, 2011 at 13:36 Comment(0)
L
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>
Labarum answered 30/1, 2011 at 22:54 Comment(11)
Is it possible to define the video element and its attributes in a second DOCTYPE and use XHTML with the video tag?Phosphorescent
@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!Labarum
@jmort253 stupid me. Of course! I can just use XHTML for the parent page and HTML5 for the frames. :)Phosphorescent
@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.Nigro
@Nigro I know, but I want it to validate. :)Phosphorescent
@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 :)Varien
@LasseBunk - This all happened over a year ago. ;) Maybe he did get through to his teacher by showing him this question.Labarum
@jmort253: Ooops, I didn't notice that :-) Yeah, we must hope that he got his teacher to require otherwise :) Have a good day :) /LasseVarien
@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.Labarum
@jmort253 Cool, thanks! BTW, what is X-Frame-Options? Do I have to use that for frames support in HTML5 or something?Cassaundracassava
@Cassaundracassava - 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: <iframe src="http://stackoverflow.com" width="800" height="1200" />, then do the same with duckduckgo.com. Good luck!Labarum
J
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.

Jenette answered 30/1, 2011 at 22:38 Comment(2)
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?Phosphorescent
Given HTML5's current and very slim support (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.Jenette
M
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.

Marti answered 30/1, 2011 at 22:39 Comment(0)
Z
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.

Zola answered 3/2, 2011 at 9:3 Comment(3)
Frames are listed as "entirely obsolete" and among those (non-conforming) features of HTML that "must not be used by authors" at w3.org/TR/html5/obsolete.html#non-conforming-features even if processing requirements are listed at w3.org/TR/html5/obsolete.html#framesKautz
@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.Anodic
I agree, but is worth noting in case browsers do act in such a manner as to entirely remove their support.Kautz

© 2022 - 2024 — McMap. All rights reserved.