HTML & CSS
I'm relatively new to the forum so forgive me if this is a naive question or something that's been asked a billion times before. This is fairly straightforward, so I'm sure it's come up here before... However, I ran a search and didn't find anything.
Basically, I can't get Youtube video embeds to work in HTML5 documents.
If I just run a normal (X)HTML document, starting with this formatting:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
I can run a youtube embed like, <iframe width="420" height="315" src="//www.youtube.com/embed/oUjUTG3hwyQ" frameborder="0" allowfullscreen></iframe> and it will show perfectly.
But if I use the HTML5 formatting:
<meta charset= "UTF-8">
I won't get a video. Instead, in Chrome, it will say "the file or directory cannot be found." In internet explorer, it will say "page cannot be displayed."
What's going on here?
The YouTube address is missing http: in the beginning.
It should be......
That is the actual code YouTube supplies, and it works OK—but I think the page has to be online for it to work. Locally (for testing purposes) you may indeed need to add in the http:// bit.
But the doctype is not the issue here.
The missing "http" is done on purpose: the URL may be HTTP, or it may be HTTPS. This can allow the browser or an app to choose which is used instead of hardcoding it.
I completely agree with ralph.m & Stomme poes. One extra point, your example html 5 isn't valid (you have two html open tags)....
... the page won't be completely valid anyway (un-tweaked YouTube embeds aren't valid html 5) but I'd definitely fix that.
This topic is now closed. New replies are no longer allowed.