www.webdeveloper.com
Results 1 to 3 of 3

Thread: Bothersome question for learning newbie!

Hybrid View

  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Bothersome question for learning newbie!

    I am working on my AS in IT and am currently taking introduction to web development. We just started classes and finished our first unit. We are at the moment learning HTML5. For our first unit we created a basic setup of HTML for our homepage. According to the reading and assignment my code was to look like this:

    <!DOCTYPE html>
    <html>
    <head>
    ...etc...

    Now here is the part that is bothering me. I got a 100 on the assignment but the professor told me I needed to take out the second line of <html>. I like to understand things and want to understand why this would need to be taken out. In my understanding the DOCTYPE gives the instruction and the html is the root element.

    So here are my questions:

    Should the <html> remain on that second line?
    If so, am I right in the explanation?
    If not, can you tell me why?
    What is the affect of having the line vs. not having the line?

    Thank you all!

  2. #2
    Join Date
    Oct 2013
    Posts
    267
    Hmm. I was also of the same belief. So I took a valid HTML5 page and removed the <html> tag. Lo and behold it validated! Apparently that's not a "required" tag anymore. However, good practice suggests keeping it, at least in my mind. For example I have the following in one of my stylesheets:
    Code:
    html{
    	min-height:100%;
    	position:relative;
    }
    If <html> isn't there that would be ignored by a web browser.

    Hopefully someone smarter than me will come along and give a better answer!

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    I don't know how you are learning HTML 5 seeing how it doesn't even exist yet but in all existing forms of HTML the HTML start and end tags are optional even though the element itself is required. That means that if you omit the tags, the browser is supposed to act as if there were there. XHTML is different, there are no optional tags.

    This leads to some interesting situations. In HTML the TBODY element is required for each TABLE element but the tags are optional. Most people are in the habit of omitting them so when they came up with XHTML 1.0 they made the TBODY element itself optional. That means that if you have an XHTML document with a TBODY-less TABLE element and it is parsed by the browser as HTML then it will insert the TBODY. But if the browser thinks that it is XHTML then the browser will not. This has huge implications for CSS and JavaScript.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles