Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Some questions about HTML  (Read 2490 times)

0 Members and 1 Guest are viewing this topic.
Some questions about HTML
« on: April 25, 2012, 01:12:55 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57
I'm not sure if this is the correct forum... it involves HTML code, not game-making code.
So anyway, I'm kind of new to HTML... well, not exactly new... I learned HTML back when it was very different... back when all tags were done in caps and closing tags on single-tag elements weren't needed and there was no CSS (example:
I learned:
Code: Text
  1. <CENTER><IMG SRC="http://www.google.com/images/srpr/logo3w.png"></CENTER>
Instead of:
Code: Text
  1. <img style="display:block;margin-left:auto;margin-right:auto;" src="http://www.google.com/images/srpr/logo3w.png" />
However, I've learned just about all the differences so it doesn't really matter.
I am confused about a few things though...

First, what is the difference between XHTML and well marked-up HTML besides the DOCTYPE and the fact that instead of writing <html> you write <html xmlns="http://www.w3.org/1999/xhtml"> and the fact that a few HTML attributes are not included in XHTML?  Are the two compatible... I mean could I literally take my web page and change the DOCTYPE and the <html> tag and have it work as XHTML (as long as I haven't used any attributes that aren't valid in XHTML)?
Also, what really is the point of HTML when XHTML exists?  It sounds as if XHTML is better, so why should I ever use HTML?

Second, I'm confused about DOCTYPEs as they didn't exist when I learned the language.  I see that there's strict, transitional, and frameset... I don't understand the purpose.  If I write code that follows the strict standards and I give it the frameset DOCTYPE then will it still run fine?  If so, what's the point in even using strict if frameset allows for strict along with other stuff?

Third, there's this "validator" program at http://validator.w3.org/ ... I assume that what that does is checks the code for errors.  However it always finds a ton of errors in my code that I know are not errors at all.  In fact, giving it Google as the page to check gives 32 errors and there's no way that there could be that many as it runs fine for everyone who uses it.  It also tends to find tons of errors in my javascript scripts saying that they aren't valid HTML (but of course they aren't valid since they aren't HTML).  Should I ignore those errors... more importantly should I ignore this validator altogether?

Lastly, I'm curious... what would an older browser do when it comes across a tag that didn't exist at the time?  Will it ignore the tag or will it print the tag to the page as if it was text?
« Last Edit: April 25, 2012, 01:14:57 pm by dannyjenn »
Logged
Re: Some questions about HTML
« Reply #1 on: April 25, 2012, 01:29:06 pm »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
Quote
Second, I'm confused about DOCTYPEs as they didn't exist when I learned the language.  I see that there's strict, transitional, and frameset... I don't understand the purpose.  If I write code that follows the strict standards and I give it the frameset DOCTYPE then will it still run fine?  If so, what's the point in even using strict if frameset allows for strict along with other stuff?

They actually did.  HTML4.01 and earlier is based on SGML and therefore has a DTD (document type definition).  If you didn't learn about this, then you probably didn't learn HTML right, most people don't.  The transitional DTD is more loose and allows you to use some presentational features such as <font face>.  Strict removes these things and expects it to be handled via CSS.  Frameset you should never touch as Frames are well...garbage at this point in time.

Quote
Third, there's this "validator" program at http://validator.w3.org/ ... I assume that what that does is checks the code for errors.  However it always finds a ton of errors in my code that I know are not errors at all.  In fact, giving it Google as the page to check gives 32 errors and there's no way that there could be that many as it runs fine for everyone who uses it.  It also tends to find tons of errors in my javascript scripts saying that they aren't valid HTML (but of course they aren't valid since they aren't HTML).  Should I ignore those errors... more importantly should I ignore this validator altogether?

To put it simply, the web is a mess.  It's error ridden, unorganized and filled with people who write invalid HTML.  Just run Amazon's site through the validation service, any real web developer will want to cry.  By invalid I mean it doesn't follow the DTD, and therefore is not standard.  What this means is that the HTML is not guaranteed to work correctly across all browsers.  The Google errors look like they point to a lot of obsolete code, such as tables.  I'm surprised Google is using tables, actually, especially considering the site is now on HTML5.  To make it short, yes you should use the validation service.  It's created by the w3, afterall. 
« Last Edit: April 25, 2012, 01:31:06 pm by MG-Zero »
Logged



i love big weenies and i cannot lie
Re: Some questions about HTML
« Reply #2 on: April 25, 2012, 04:01:56 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
So anyway, I'm kind of new to HTML... well, not exactly new... I learned HTML back when it was very different... back when all tags were done in caps and closing tags on single-tag elements weren't needed and there was no CSS (example:
I learned:
Code: Text
  1. <CENTER><IMG SRC="http://www.google.com/images/srpr/logo3w.png"></CENTER>
Instead of:
Code: Text
  1. <img style="display:block;margin-left:auto;margin-right:auto;" src="http://www.google.com/images/srpr/logo3w.png" />
However, I've learned just about all the differences so it doesn't really matter.
I am confused about a few things though...
Actually, you were never required to use all-caps for HTML tags in the past - it was kind of a (poor) convention to help in noticing the differences between tags and content. HTML itself is actually case-insensitive.

First, what is the difference between XHTML and well marked-up HTML besides the DOCTYPE and the fact that instead of writing <html> you write <html xmlns="http://www.w3.org/1999/xhtml"> and the fact that a few HTML attributes are not included in XHTML?  Are the two compatible... I mean could I literally take my web page and change the DOCTYPE and the <html> tag and have it work as XHTML (as long as I haven't used any attributes that aren't valid in XHTML)?
XHTML is an effort to bring HTML into a more XML-like strictness to ease document parsing because properly-formatted XHTML documents can be parsed by XML parsers, whereas traditional HTML requires a unique processing engine. The xmlns attribute included in the HTML tag defines the XML namespace for the document. Simply changing the DOCTYPE wouldn't break the function of your page, but it would not necessarily parse well with an XML parser -- which is what the W3C Validator exists to show. Selecting your DOCTYPE is only a matter of opting to go with a specific standard.

Also, what really is the point of HTML when XHTML exists?  It sounds as if XHTML is better, so why should I ever use HTML?
Just varying standards. The web is kind of a mess right now, really, and it's easier to teach proper HTML before covering XHTML.

Second, I'm confused about DOCTYPEs as they didn't exist when I learned the language.  I see that there's strict, transitional, and frameset... I don't understand the purpose.  If I write code that follows the strict standards and I give it the frameset DOCTYPE then will it still run fine?  If so, what's the point in even using strict if frameset allows for strict along with other stuff?
See my above response regarding XHTML. You should never, ever use frames anymore, they're disgusting little practices that are worse (in my opinion) than scrolling marquees.

Third, there's this "validator" program at http://validator.w3.org/ ... I assume that what that does is checks the code for errors.  However it always finds a ton of errors in my code that I know are not errors at all.  In fact, giving it Google as the page to check gives 32 errors and there's no way that there could be that many as it runs fine for everyone who uses it.  It also tends to find tons of errors in my javascript scripts saying that they aren't valid HTML (but of course they aren't valid since they aren't HTML).  Should I ignore those errors... more importantly should I ignore this validator altogether?
The errors it finds (as I mentioned earlier) are related to how well your document follows your selected standard. They may not cause rendering issues (though they might across various browsers), but it's still a matter of improper formatting. Basically, the biggest thing to look for is making sure that you aren't using deprecated tags (such as <center>), leaving formatting such as that to CSS documents (in that specific case, align: center), and making sure that you're closing standalone tags (such as
 and <img />).

Lastly, I'm curious... what would an older browser do when it comes across a tag that didn't exist at the time?  Will it ignore the tag or will it print the tag to the page as if it was text?
Depends on the browser. Usually, it'll simply ignore them. Still, most of what you'll use will be recognized by any semi-modern browser -- I think the oldest you'll ever have to deal with is Internet Explorer 6, and even the U.S. military has moved on to IE7 and newer. (Take it from my experience, that is a huge deal. <_<)
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: Some questions about HTML
« Reply #3 on: April 26, 2012, 02:57:17 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57
To clarify... I wasn't saying I was going to use frames, what I meant was what would happen if I wrote perfect XHTML (with no frames) but gave it the HTML4.01 Frameset DTD? (which I'm guessing would be the least strict one besides no DTD at all)  Would it display properly, since a perfect XHTML page with no frames fits all the criteria for that DTD... or do the XHTML DTDs do something different?  Do the DTDs make the page function worse as you become less strict (so XHTML Strict would always work properly, whereas HTML4 Frameset might not (assuming that the code follows all the XHTML Strict criteria))?

Oh, and another question... what exactly is bad about using the <table> tags to do layout?  I keep seeing all these websites / people saying "Never use tables for layout!" but no one ever explains why... the few things that I've heard were:
- It's only done out of laziness (which I don't see why it matters... if the page runs fine I could care less if a web page designer was lazy or not)
- The code is harder to read / write (which I disagree with... and it doesn't need to be easy to read / write anyway.  Saying bold textitalic textunderline text is a lot easier to read and write than <span style="font-weight:bold;">bold text</span><span style="font-style:italic;">italic text</span><span style="text-decoration:underline;">underline text</span>, yet the one with the CSS is the one to use).
- The table has to load in an extra element or something so it loads more slowly (this makes absolutely no sense... a single table isn't going to noticeably slow the page at all...)
- It's bad for accessibility (like if someone has the browser read the page to him... however, this doesn't really matter for the purposes of my page (which isn't meant to have the contents spoken) and additionally I can get the brower's speech option to work fine in a table)
Does anyone have an actual reason other than personal opinion / preference as to why tables should never be used for layout?  Just wondering... my layout actually doesn't use tables but I don't understand why people say to avoid it like it's the plague.
« Last Edit: April 26, 2012, 02:59:38 am by dannyjenn »
Logged
Re: Some questions about HTML
« Reply #4 on: April 26, 2012, 03:47:18 am »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
To clarify... I wasn't saying I was going to use frames, what I meant was what would happen if I wrote perfect XHTML (with no frames) but gave it the HTML4.01 Frameset DTD? (which I'm guessing would be the least strict one besides no DTD at all)  Would it display properly, since a perfect XHTML page with no frames fits all the criteria for that DTD... or do the XHTML DTDs do something different?  Do the DTDs make the page function worse as you become less strict (so XHTML Strict would always work properly, whereas HTML4 Frameset might not (assuming that the code follows all the XHTML Strict criteria))?
Doctypes only define the standard you wish to use, and (to my knowledge) have no effect on the actual rendering of the page.

Oh, and another question... what exactly is bad about using the <table> tags to do layout?  I keep seeing all these websites / people saying "Never use tables for layout!" but no one ever explains why... the few things that I've heard were:
Tables used to be the standard layout tool, but are frowned upon in modern web design because it is more efficient to use a combination of Div tags with CSS styling. The introduction of CSS has generally caused Tables to return to their originally-intended use: sorting data in a table format.

- It's only done out of laziness (which I don't see why it matters... if the page runs fine I could care less if a web page designer was lazy or not)
Like doctypes, it's more of a Standards issue, rather than function. It's become standard practice to use Divs rather than tables - most sites that currently use tables are doing so because they were designed as such for years. The current theme on this forum, for example, is still heavily table-based, as are most web forums at the moment.

- The code is harder to read / write (which I disagree with... and it doesn't need to be easy to read / write anyway.  Saying bold textitalic textunderline text is a lot easier to read and write than <span style="font-weight:bold;">bold text</span><span style="font-style:italic;">italic text</span><span style="text-decoration:underline;">underline text</span>, yet the one with the CSS is the one to use).
Actually, and have been deprecated and replaced with <strong> and (emphasis), but I do see your point. Most browsers still support the older tags, however.

>
- The table has to load in an extra element or something so it loads more slowly (this makes absolutely no sense... a single table isn't going to noticeably slow the page at all...)
Not quite sure where they were going with this. Even if that were true, it's nowhere near enough of a performance issue to have any impact.

- It's bad for accessibility (like if someone has the browser read the page to him... however, this doesn't really matter for the purposes of my page (which isn't meant to have the contents spoken) and additionally I can get the brower's speech option to work fine in a table)
There are some issues with accessibility features, such as web readers and magnification. This is mostly a User Experience issue, when you have disabled users attempting to use your website. Which, at this level, you really don't have to worry all that much about.

Does anyone have an actual reason other than personal opinion / preference as to why tables should never be used for layout?  Just wondering... my layout actually doesn't use tables but I don't understand why people say to avoid it like it's the plague.
Just about everything dealt with here is a Standards issue, rather than functional issues. People avoid it like the plague because less experienced users tend to exaggerate what they are told by more experienced users, and experienced users tend to exaggerate what they tell less-experienced users. It will be years before any of the now-deprecated functionality no longer functions, so you don't have much to worry about.

Still, if you're considering doing web development in any serious capacity, you're going to want to drop the use of tables and learn to do Div-based interfaces. Ultimately, DIVs with CSS are more capable than tables.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.404 seconds with 48 queries.