Computer HardwareXbox GamesGameCubePlaystation 2PSOnePC/Windows GamesGameboy AdvanceDreamcastNintendo 64Gameboy ColorNintendo DSSony PSPXbox 360Nintendo Wii GamesPS3 Games

Neoseeker Forums » Programming and Design » HTML/CSS & NeoHome Help » "Teaching" HTML the Correct Way

Moderated by: Chiggins
REPLY TO THIS THREAD   START NEW THREAD
Options: Print   subscribe   remove   send to friend   PM this thread to a friendNeoPM
subscribe to thread Topic: "Teaching" HTML the Correct Way
Tom
Nec Aspera Terrent
Neo or Bust

wiki staff
gta




Tom's profileTom's neohomeEmail TomNeoPM TomTom's Fan Art!
total posts: 7285
neopoints: 214
GameGrep pts: 267
since: Apr 2006
Nov 08, 09 at 10:19pm
"Teaching" HTML the Correct Way

More and more, people are learning to create web pages using HTML, but I think that it's very important that if we are to show people how to do something, then we show them how to do it correctly.

There are a lot of tags which are still being used in examples, even though they are deprecated, which means that effectively the person is going to learn how to do things the wrong way.

HTML should always be tested in the W3C Validator, and only if it has been passed by the validator should it be used.

There is only one way of doing something, and that is the right way!

People often complain that Internet Explorer doesn't always work correctly with their web pages, and most of the time it's because the person isn't using correct HTML standards. I've always found that if you avoid deprecated tags and follow a Strict DocType with correct standards, then the errors are reduced to a bare minimum.

The first point that I'll highlight on that is to avoid deprecated tags. <b > and <u > tags are both deprecated, as are the <strike>, <font> and <center> tags. These are all tags which people are commonly using in Neohomes and web pages, even though technically they shouldn't. There are alternatives that do the exact same job, which are supported in all browsers and will be for a long time to come, whereas these deprecated tags will be decommissioned eventually, and will cause all sorts of bugs. And why are a growing number of people making this mistake? Because the people that help them and "show them how" use the wrong standards themselves, and it becomes like a plague spreading on an exponential scale.

Another major pointer is that if a tag should be closed, then do it. A lot of people don't bother to close <li > or <p > tags because they don't have to.

Just because you don't have to doesn't mean you shouldn't!

This is another major problem - if you don't close your tags, then this can cause a lot of issues in terms of display. The only time you shouldn't have an ending tag is when the tag shouldn't have one. For example, the <img /> tag closes itself.

Please, dear God, no capitals!

You'll also notice that HTML tags are all supposed to be written in lower case, but yet a lot of people like to take a nostalgia trip to the 1990s and write everything in capitals. Not only does this look damn ugly, it's also not a valid standard and hasn't been for more years than anyone dares to count.

Use UTF-8 and encode your characters! There is nothing more annoying than seeing little squares or question marks where a special character couldn't be displayed because the character sets clashed. It's as simple as putting something like this in your <head> tags...

code
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>


Then it's merely a case of encoding your characters. For example if you were to put an acute e (é), then you should encode your character... é That's all it takes. That little bit of extra effort will minimise this issue, and if you're linking to a URL then it's important to put & in place of any ampersands.

Next thing I'ma highlight is the importance of using all the correct tag attributes. You may not be aware, but correct standards ask that all <img /> tags carry the alt attribute. There are many more tags that require certain attributes as part of the correct standards, and it's important that these are used, mainly for accessibility purposes. Try disabling the stylesheet in a web page (for Firefox users see View > Page Style > No Style), and you'll see the web page as it appears without CSS. Take a Cynthia Test to see just how good your web page is for those with disabilities and accessibility issues, and think how you would like it if you couldn't access a site because the web designer didn't take the effort to create the page correctly.

I could go on forever about accessibility and the different things you should do. For example, all pages should have an <h1> tag, and should be split into various subsections using other tags such as <h2>, and all pages should have some kind of breadcrumb trail and clear navigation systems. All pages should still operate even if Javascript, Flash or CSS are disabled... The list goes on.

I thought it important to highlight the many different things which people should do to help make things better for the future of the web, because if we teach incorrect standards now, then we'll just have to get out of an even bigger hole in the future.

If anyone would like to contribute to anything that I've mentioned here, add your own tips or correct something I've said, then please feel free.


-------------------

Get Rick Roll'd by my Neohome while you still can!
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Chiggins
(devpen) (crs) (badass)
(moderator)

HTML/CSS & NeoHome Help




Chiggins' profileChiggins' neohomeEmail ChigginsNeoPM ChigginsChiggins' gallery (410 images)
total posts: 2417
neopoints: 191
GameGrep pts: 613
since: Jun 2003
Nov 08, 09 at 10:45pm
re: "Teaching" HTML the Correct Way

I totally agree with this. There is almost nothing more painful than to see incorrect code being taught.

At my university, all computer/information system majors have to take ITK 160 (Introduction to Computer Concepts). Right now we are on the internet/networking chapters. One day in lecture, we were taught HTML. My God, I wanted to just stop my professor and teach the damn class myself. The PowerPoint slides showed off HTML code being in ALL CAPS, attributes formatted as: attribute_name = value, instead of: attribute_name="value". Image and line break tags were also shown as non-self closing.

It was just such a disgrace to see this.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Quierta
Nov 09, 09 at 4:57am
re: "Teaching" HTML the Correct Way

My web design teacher took all the DOCTYPE coding out of his website and web pages, then told another student that the reason her page was messed up was because "Dreamweaver puts in this funny DOCTYPE code at the top of all the pages. If you remove that I'm sure you'll find that your page works much better".

I immediately corrected him.

Sweet Jesus, man.


-------------------

This is Jeffrey; he's a dragon. A dancing dragon.
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Stormy
Still Seekin'



Stormy's profileStormy's neohomeNeoPM Stormy
since: Feb 2006
Nov 09, 09 at 5:37am
re: "Teaching" HTML the Correct Way

This was very informative; thanks for writing it.

I just have a question though.... Why exactly are some tags "deprecated"? I know there are other ways to get the same effect like you said, but what's wrong with doing it an old way? I've been using <b > for a while and never knew it was deprecated. >.>

Edit: Gahh, I had a teacher kind of like that. <_< I doubt she even knew or cared what "DOCTYPE" meant, or even noticed it was there. She made us all work strictly with the layout mode where you click and drag boxes to make tables and lectured me when I tried to use Notepad or the code view. I hated that class so much. >_>


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Chiggins
(devpen) (crs) (badass)
(moderator)

HTML/CSS & NeoHome Help




Chiggins' profileChiggins' neohomeEmail ChigginsNeoPM ChigginsChiggins' gallery (410 images)
total posts: 2417
neopoints: 191
GameGrep pts: 613
since: Jun 2003
Nov 09, 09 at 8:57am
re: "Teaching" HTML the Correct Way

I know that in the case of the difference between b/strong and i/em, the latter of the pair work with screen readers. When the screen reader is reading out the text, it puts the correct emphasis on the strong's and em's.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Tom
Nec Aspera Terrent
Neo or Bust

wiki staff
gta




Tom's profileTom's neohomeEmail TomNeoPM TomTom's Fan Art!
total posts: 7285
neopoints: 214
GameGrep pts: 267
since: Apr 2006
Nov 09, 09 at 5:19pm
re: "Teaching" HTML the Correct Way

I tell a lie when I say the <b > tag is deprecated - it isn't (although <strong > is preferred), but I imagine it will be some time in the future.

To be honest, Stormy, I don't know why <strong > has come in to replace <b >, although I'm sure if I was to read through the hundreds of pages of documentation I'd find it somewhere... The technicalities of why tags become deprecated is a mystery to me - I just know that it is, and therefore using it is incorrect. And what you say highlights my point perfectly - you say that you didn't know that the <b > tag was deprecated, and this won't be your fault - it'll be the fault of wherever you learned HTML.

One thing I should stress is that people who use HTML should check every now and again for any tags becoming deprecated. This means that they can then edit their code to be correct, and they can avoid making errors in the future. Once you start using HTML, it is your own responsibility to keep up to date with it.

Check here for a list of supported and deprecated tags...


-------------------

Get Rick Roll'd by my Neohome while you still can!
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Devastate
unwashed heathen
(moderator)

Action [PSP]




Devastate's profileNeoPM Devastate
total posts: 775
since: Jul 2009
Nov 09, 09 at 5:24pm
re: "Teaching" HTML the Correct Way

HTML tags written in full caps are the ugliest things ever. :/



quote   quick quote   edit   quick edit   del  searchposts in thread  report
Artificer
Nov 09, 09 at 6:04pm
re: "Teaching" HTML the Correct Way

To answer your question, Stormy, over time the designers of HTML added new capabilities to the language that are either easier or "more correct" than previous methods, an example of which is using CSS to style instead of various HTML attributes (like height, width, bgcolor, etc.). Thus, these older ways of doing things have been deprecated in favor of the new features of the language.


-------------------
100% of innovation—from business to politics—is inspired not by "market analysis" but by people who are supremely pissed off by the way things are.

Tom Peters
quote   quick quote   edit   quick edit   del  searchposts in thread  report
RikkusRukkus
Two much Neo



RikkusRukkus' profileRikkusRukkus' neohomeNeoPM RikkusRukkus
since: Aug 2003
Nov 09, 09 at 6:36pm
re: "Teaching" HTML the Correct Way

Actually, using uppercase tag names is perfectly valid in HTML 4.01 and HTML 5. That doesn't mean I won't stab anyone who writes like that, though.

quote
Image and line break tags were also shown as non-self closing.
Self closing tags aren't valid HTML, they're XHTML. They're not the same. HTML is based on SGML, XHTML is based on XML. Self closing tags are valid in (X)HTML 5 and you may mix and match coding styles, but in HTML class where they teach HTML, <br> is correct ;) .

quote
Why exactly are some tags "deprecated"?
Some ideas sound good when they're implemented, but turn out to be unneeded or just plain stupid in the future. In the PHP world, for example, there's something called Register Globals. Sounded neat at first, but nobody in their right mind would advise you to use them now.

Early versions of HTML relied on tags like <b> and <font> for formatting since it was the only way to make your document all pretty and neat. Style sheets are a far better alternative, so now the official advice is: ``Don't use presentational tags, use CSS´´. But you can still use them, for backwards compatibility. <strong> isn't the same as <b>. <b> stands for 'bold', <strong> stands for ``THIS IS REALLY PRETTY IMPORTANT, Y'ALL´´ or somesuch. <em> is emphasize. Most browsers will render them bold and in italic, but they don't need to. If you want, you could change <strong> to 'T H I S' and that wouldn't be wrong. Better than sticking <span>s and <div>s all over the place.

For all of my documents, I use HTML 4.01 Strict and I advise you to do the same. If you must, use XHTML 1.0. IE doesn't really understand XHTML 1.0 (``what are all those funny slashes doing in my <img>?´´ but will render (most of the time) in Standards Mode and not in Quirks Mode.
XHTML 1.1 and 2.0 are useless for the web. 1.1 and 2.0 must be sent to the user agent as 'application/xhtml+xml', 1.0 may, but it isn't mandatory. Browsers that don't support XHTML will prompt you with a download window (``this is an XML file, what am I supposed to do with this?´´ and browsers that do support XHTML may not render your document at all if there is even a slight syntax error. With today's user generated content and editors such as CKEdtor and TinyMCE, that won't do at all.
So HTML 4.01, XHTML 1.0 or HTML 5 (Google.com uses it!) whenever that takes off, since it's backwards compatible.

And I assume everyone here knows about Conditional Comments, right? They're the perfect way of sending IE-only code to browsers in a standards compliant, failsafe, low overhead, JavaScript-free method.
code
<!--[if IE]>
You are using Internet Explorer (any version)
<![endif]-->

<!--[if IE 6]>
You are using Internet Explorer 6
<![endif]-->

<!--[if lte IE 7]>
You are using IE7 or below.
<![endif]-->

<!--[if !IE]><!-->
You are NOT using Internet Explorer!
<!-- <![endif]-->

Haven't found a use for the last one, (I only use CCs to include an IE6 CSS file, 7 and 8 are easy enough to handle) but it's so ingeniously genius, I had to mention it.


-------------------
Something.
quote   quick quote   edit   quick edit   del  searchposts in thread  report
bobbonew
Nov 09, 09 at 7:10pm
re: "Teaching" HTML the Correct Way

I agree wholeheartedly with this thread (I got off topic though, and branched off to this thread about javascript).

HTML is ever still, a journey to conquer person to person.
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Tom
Nec Aspera Terrent
Neo or Bust

wiki staff
gta




Tom's profileTom's neohomeEmail TomNeoPM TomTom's Fan Art!
total posts: 7285
neopoints: 214
GameGrep pts: 267
since: Apr 2006
Nov 09, 09 at 7:52pm
re: "Teaching" HTML the Correct Way

In answer to RikkusRukkus, all-caps tags and not self-closing may be correct, but the point that I'm making is that it's not good practice. It's like I said, just because you CAN do something, doesn't mean you SHOULD.

It's like with SSS, code indentation and commenting is something that should be done. You don't have to do it, and the code will work if you don't, but most people do simply because it's good practice, and that's the major difference between doing something and not doing it. It's not because we HAVE to, it's because it's the sign of good, well-written and easy to maintain coding.


-------------------

Get Rick Roll'd by my Neohome while you still can!
quote   quick quote   edit   quick edit   del  searchposts in thread  report
RikkusRukkus
Two much Neo



RikkusRukkus' profileRikkusRukkus' neohomeNeoPM RikkusRukkus
since: Aug 2003
Nov 09, 09 at 9:38pm
re: "Teaching" HTML the Correct Way

Self-closing tags in HTML versions before 5 are invalid, plain and simple. I personally don't care if they're added, but it's not to spec.

I agree with the notion that uppercase tags should not be used, for readability and consistency. They shouldn't be used, but they're valid HTML. That's exactly what I said in my post.
I personally feel that (for example) CSS classes should always use dashes to separate words and that they should not be CamelCased, but such class names are valid. I also leave off the closing PHP tag (?>), that's valid, but you might not like doing that personally.


-------------------
Something.
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Tom
Nec Aspera Terrent
Neo or Bust

wiki staff
gta




Tom's profileTom's neohomeEmail TomNeoPM TomTom's Fan Art!
total posts: 7285
neopoints: 214
GameGrep pts: 267
since: Apr 2006
Nov 09, 09 at 10:36pm
re: "Teaching" HTML the Correct Way

This is exactly what I'm saying. Not to get too much into SSS, but look at if statements - you don't HAVE to enclose them inside curled braces if the code is only one line - it's still valid and it works, but it shouldn't be done.

Again, I always put the ?> tag, because I personally view it as the correct way of doing things. The way I see casing is that I always use dashes to separate words in CSS. In SSS, I use CamelCasing for classes, namespaces and interfaces, I use all lowercase with underscores to separate words when dealing with functions/methods, and when I'm using variables I semi-CamelCase it by starting with a lower case then any proceeding word will begin with a capital.

It's not a case of what's valid and what's not valid really, for example leaving off the ?> may well be valid, it's more a case of what is preferred standards.

Btw, regarding the self closing tags, put this code into the W3C Validator...

code
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Hi</title>
</head>
<body>
<p><br /></p>
</body>
</html>


And you'll find that it doesn't call the self closing break tag invalid - it just outputs a warning that some browsers may not interpret in the same way as others.


-------------------

Get Rick Roll'd by my Neohome while you still can!
quote   quick quote   edit   quick edit   del  searchposts in thread  report
RikkusRukkus
Two much Neo



RikkusRukkus' profileRikkusRukkus' neohomeNeoPM RikkusRukkus
since: Aug 2003
Nov 09, 09 at 10:49pm
re: "Teaching" HTML the Correct Way

quote http://validator.w3.org/docs/errors.html
63: character data is not allowed here
    You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:
    • putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or
    • forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
    • using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.
Just because the validator doesn't pick it up, doesn't mean it's correct.

In fact, browsers don't even like this. Straight from the Webkit (Safari/ Chrome's render engine) development team:

quote http://webkit.org/blog/68/understanding-html-xml-and-xhtml/
It’s important to note that this is kind of a hack, and depends on the de facto error handling behavior of HTML parsers. They don’t really understand the XML self-closing syntax, but writing things this way makes them treat / as an attribute, and then discard it because it’s not a legal attribute name. And if you tried to do something like <div />, they wouldn’t understand that the div is supposed to be empty.
In short, they handle '<br />' as '<br invalidAttributeParserErrorDangerDanger>'

The above article is pretty interesting, it's not very long.


-------------------
Something.
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Artificer
Nov 10, 09 at 1:42am
re: "Teaching" HTML the Correct Way

Well, to be fair, the "invalidAttributeParserErrorDangerDanger" is the behavior of an HTML parser, not an XML parser.

But since most XHTML writers probably aren't serving their documents as the correct MIME type anyway, it doesn't really matter. (And there are many problems with this. See (1), (2), (3).)

PS Yes I stole these links from the webkit blog—very nice article, I must say.


-------------------
100% of innovation—from business to politics—is inspired not by "market analysis" but by people who are supremely pissed off by the way things are.

Tom Peters
quote   quick quote   edit   quick edit   del  searchposts in thread  report
[All dates in (PT) time]Threads List   « Next Newest   Next Oldest »
REPLY TO THIS THREAD   START NEW THREAD


search:
Neoseeker Forums » Programming and Design » HTML/CSS & NeoHome Help » "Teaching" HTML the Correct Way



Jump to another forum:

Powered by neoforums v0.9.7g (equilibrium)
Copyright Neo Era Media, Inc. 1999-2009

neoseeker forum community
Neoseeker.com   |   Forum Rules   |   Forum FAQ   |   Neoseeker Terms of Use   |   Supermods On Duty [ server id: ascension ··· elapsed: 0.0957839489]
Affiliated sites:   GameGrep - Football Manager Wiki - Halo Wiki - MGS Wiki - GTA Wiki - Smackdown Wiki - Zelda Wiki - PS2seeker - Xbox seeker - DEVPEN - GFXcess