English subtitles

← XML and HTML Solution - Web Development

Get Embed Code
4 Languages

Showing Revision 6 created 05/25/2016 by Udacity Robot.

  1. The first answer--all HTML is XML--that's not true.
  2. Despite the similarity between the two, HTML can have things in it that are not valid in XML.
  3. A good example was the void tag--the tag--with no closer.
  4. All XML is HTML.
  5. This is also not true, but it is borderline acceptable.
  6. You could certainly--if you had an XML document that was full of all HTML tags
  7. it would be very close to HTML and would actually probably render in a browser just fine.
  8. For example, if you included in your browser something like this--
  9. and opening and closing tag--it would actually probably render just fine.
  10. Actually, that's a good question. I'd invite you to see if this enters one new line or two.
  11. I honestly don't know off the top of my head, and I'm not going to quiz you on it.
  12. Now, the next answer--HTML can be expressed in XML. That is true.
  13. When we use the doc type XHTML instead of just HTML,
  14. that says the following HTML document is actually going to be a valid XML document,
  15. and you can parse it as such.
  16. You don't have to look for broken tags.
  17. Your browser doesn't do less work.
  18. It's not expecting the HTML to be somewhat sloppy as HTML often is.
  19. If you say it's in XML, it'd better be in XML though,
  20. because the browser is not going to be quite as lenient on you.
  21. The final answer--XML and HTML share a common lineage--this is also true.
  22. Remember their ancester is SGML, which stands for Standard Generalize Markup Language.
  23. There are actually many other types of documents that descended from SGML,
  24. and HTML and XML are the two that will affect our lives in this course.
  25. Okay, let me just show you some doc types in the browser
  26. now that we have a little bit more of a framework to understand these.
  27. If I were to go to Wikipedia, and I were to view the source of Wikipedia,
  28. I would see that the doc type is HTML.
  29. This means HTML5. I know it doesn't say 5, but trust me on this one.
  30. Doc type HTML means HTML5, which is the most modern version of HTML we have.
  31. Now, if I were to go to a particular Wikipedia page, the Wikipedia page for SGML, for example,
  32. and I were to look at the source of this page,
  33. we see that the doc type is actually XHTML.
  34. It's actually XHTML transitional, which basically means the document is going to be in XML
  35. but will have some non-standard things in there.
  36. I'm not going to get into too much of how this affects things,
  37. but it does make some browsers behave differently.
  38. Why Wikipedia has two different doc types on two different pages I cannot explain to you.
  39. Although I can offer one guess, which is the SGML page is probably generated dynamically,
  40. and the front page is probably a nearly static page that are served from two different servers
  41. or two different machines, which is fine. You see things like this all over the internet.
  42. But when you see XHTML that means every tag in here should have a closing tag.
  43. You can see, for example, some of these header tags are these little void tags
  44. that have the closing slashes.
  45. You wouldn't see that in most HTML5 documents,
  46. although any browser would accept it, because it doesn't actually hurt anything.