SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Weird As Hell HTML5 Issue

    Hey guys,

    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"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <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:

    <!DOCTYPE html>
    <html lang="en">
    <html>
    <head><title>html5 site</title>
    <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?

  2. #2
    SitePoint Enthusiast scout1idf's Avatar
    Join Date
    Nov 2009
    Location
    Ohio
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Andy Button View Post
    Hey guys,

    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"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <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:

    <!DOCTYPE html>
    <html lang="en">
    <html>
    <head><title>html5 site</title>
    <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......

    src="http://www.youtube.com/embed/oUjUTG3hwyQ"

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,319
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by scout1idf View Post
    The YouTube address is missing http: in the beginning.
    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.

  4. #4
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    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.

  5. #5
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I completely agree with ralph.m & Stomme poes. One extra point, your example html 5 isn't valid (you have two html open tags)....

    <!DOCTYPE html>
    <html lang="en">
    <html>
    <head><title>html5 site</title>

    ... the page won't be completely valid anyway (un-tweaked YouTube embeds aren't valid html 5) but I'd definitely fix that.
    Jon Matthews - founder - Deep Cognition Ltd.
    http://deepcognition.com/mTrawl.htm - Free for Windows & Mac;
    check your links and validate all your html with one click


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •