Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

72 users online



[Article] kiswa's Aricle Part 1: Standards and Semantics

[Article] kiswa's Aricle Part 1: Standards and Semantics

Currently viewing this thread: 1 (0 members and 1 guests)


kiswa

kiswa

Yeah, kiswa.
Status: Offline!

[Article] kiswa's Aricle Part 1: Standards and Semantics

I posted this article on another site a little while back. It was fairly well received there, and I thought I'd post it here to hopefully help people understand this subject. If there's anything you feel I've missed, or stated incorrectly, please let me know!
___________________________________________________________

Web Standards and Semantic Markup - What and Why

-

What Are Web Standards?
??The W3C develops open specifications (de facto standards) to enhance the interoperability of web-related products.? Basically, The W3C (World Wide Web Consortium) creates recommendations in working groups that involve Consortium members and field experts. These groups submit recommendations to the W3C membership and director for formal approval.

These standards are used to define methods of adding structure to text files (HTML, XHTML, and XML), techniques for styling the structural markup (CSS), and the DOM (Document Object Model) that is used by scripting languages.

Why Use Web Standards?
Accessibility. The most important reason standards exist is to give your sites greater reach and accessibility. Writing your code to be semantic and standards compliant will make your site more transparent to search engines, robots, server-side and client-side scripting, and users with special needs.

When a site is written semantically (more on this later) and follows the standards it is accessible to the most browsers possible. Older browsers will be able to understand the basic structure of your document (even if they can??t do all the new styling), current browsers can do it all (except IE which doesn??t follow the standards for CSS and therefore requires hacks), and future browsers will also work (at least with the coding if not the styling). You??ve got all the bases covered if you follow the standards.

Another benefit to standards compliant documents is that they can be more easily converted into other formats. You can take a standards compliant web page and make a Word document easily. They are also easier to migrate to new systems, such as TV browsers, PDAs, cell phones, screen readers, Braille browsers, etc.

By using standards compliant markup in your sites, you are guaranteeing the largest possible market for your sites.

Semantics?
So, what do I mean when I talk about semantic markup? Here??s an example of a simple site that has a header, navigation, main text area and footer:

Non-Semantic Markup:

Code:

<html>
<head>
<title>Test</title>
</head>

<body>

<div id="header">
<div id="header_text">This is the Page Title</div>
</div>

<div id="nav">
<div class="nav_item">Item 1</div>
<div class="nav_item">Item 2</div>
<div class="nav_item">Item 3</div>
</div>

<div id="main_text">
<div class="main_text_title">Paragraph Title</div>
<div class="main_text_paragraph">This is some filler text... This is some filler text... This is some filler text... <br />
This is some filler text... </div>
<div class="main_text_title">Paragraph Title</div>
<div class="main_text_paragraph">This is some filler text... This is some filler text... This is some filler text... <br />
This is some filler text... </div>
</div>

<div id="footer">
<div id="footer_text">Copyright 2005 All Rights Reserved.</div>
</div>

</body>
</html>

Semantic Markup (sorta, see note below):

Code:

<html>
<head>
<title>Test</title>
</head>

<body>

<div id="header">
<h1>This is the Page Title</h1>
</div>

<div id="nav">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>

<div id="main_text">
<h3>Paragraph Title</h3>
<p>This is some filler text... This is some filler text... This is some filler text...
<br />This is some filler text... </p>
<h3>Paragraph Title</h3>
<p>This is some filler text... This is some filler text... This is some filler text...
<br />This is some filler text... </p>
</div>

<div id="footer">
<p>Copyright 2005 All Rights Reserved.</p>
</div>

</body>
</html>

Okay, technically this isn't really semantic code. It includes not entirely necessary code (all the div's). However, I did this because it prepares the semantic document for easy styling by using CSS. I'll go into that in more detail in a future article if you're interested, so let me know!

Whats the Difference?

I'm glad you asked. The difference is how the structure of the document is created by the semantic markup. The first example would look like this on a text browser (or if the stylesheet didn't load for any reason):

Quote:


This is the Page Title
Item 1
Item 2
Item 3
Paragraph Title
This is some filler text... This is some filler text... This is some filler text...
This is some filler text...
Paragraph Title
This is some filler text... This is some filler text... This is some filler text...
This is some filler text...
Copyright 2005 All Rights Reserved.


This is how the semantic document would look in the same browser (still no styling)*:

Quote:


This is the Page Title

* Item 1
* Item 2
* Item 3

Paragraph Title

This is some filler text... This is some filler text... This is some filler text...
This is some filler text...

Paragraph Title

This is some filler text... This is some filler text... This is some filler text...
This is some filler text...

Copyright 2005 All Rights Reserved.


Notice the difference? By using the appropriate tags to create a semantic structure for your document, you will create a site that 'makes sense' to text browsers, the DOM, screen readers, etc. And if for some reason your stylesheet doesn't load, your visitors still get to see a site that makes some visual sense. Which would you rather have?

*The look of this version is 'typical' and would of course vary depending on what viewer is being used.

Source:
http://www.webstandards.org/learn/faq/

Next Time - kiswa's Article Part 2: DOCTYPE

___________________

www.kiswa.com
My attempt at articles for Neverside CodeBase: Part 1 Part 2 Part 3
(. )v( ) <- The Webstandards Owl

Last edited by Locke, May 26th, 2005 12:04 PM (Edited 9 times)

Locke

Locke

"Refocusing" My Time
Status: Offline!

Very well written article, thanks for contributing.

___________________

The Audoptic Weblog. It's where the magic happens.

Simon

Simon

Jag är Gandalf den grå och den vite, men vem är du?
Status: Offline!

Great, good to see something coming in. Here is a cuple of things that I reflected over though.

Semantic markup and valid/standards compliant code isn't the same thing. Now, I'm sure you know that but some of the paragraphs could be confusing to the readers.

The semantic markup:

Code:

<html>
<head>
<title>Page title</title>
</head>

<body>

<h1>This is the Page Title</h1>

<hr />

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

<h3>Paragraph Title</h3>
<p>This is some filler text... This is some filler text... This is some filler text...<br />
This is some filler text...</p>

<h3>Paragraph Title</h3>
<p>This is some filler text... This is some filler text... This is some filler text...<br />
This is some filler text...</p>

<hr />

<p>Copyright 2005 All Rights Reserved.</p>

</body>
</html>

Just removed all the non content describing tags (div's), they aren't supposed to be there unless they really have to. (since this is an article on markup and not CSS or JavaScript)
Oh, that and I added a missing </head> plus two breaks for footer and header. (thats discussable ofcourse, I think they are important in markup personaly) Smile

Futher more it would be great if you could cover some important things like meta tags (content type especialy), important attributes on tags and doctypes. All this belongs in the subject too.

Great article, good work.

___________________

Neversidian, your staff is broken.

Last edited by Simon, May 25th, 2005 07:23 PM (Edited 4 times)

kiswa

kiswa

Yeah, kiswa.
Status: Offline!

Thanks guys!

Simon, you got me there. Technically, you're right... but I wanted to create a semantic example of a site that is being setup for future CSS styling. I mean, who's going to write a site that's purely semantic and not have the DIVs to hook into for their CSS styling?

And wow, I can't believe I completely ignored META tags... I'll at least edit it to cover DOCTYPE as that's pretty damn important. Thanks for noticing that!

I'll have to ponder how I want to re-write this... but I'll definitely go back through it and add some mention of why the technically non-semantic code is in my semantic example and add a bit on at least the doctype meta tag!

___________________

www.kiswa.com
My attempt at articles for Neverside CodeBase: Part 1 Part 2 Part 3
(. )v( ) <- The Webstandards Owl

Simon

Simon

Jag är Gandalf den grå och den vite, men vem är du?
Status: Offline!

Great! Once again, good job on this.

___________________

Neversidian, your staff is broken.

Locke

Locke

"Refocusing" My Time
Status: Offline!
Quote:


I'll have to ponder how I want to re-write this... but I'll definitely go back through it and add some mention of why the technically non-semantic code is in my semantic example and add a bit on at least the doctype meta tag!

Make it a series, if you make an article too big, people are less inclined to read it. So break it up into a series and cover difference aspects of this subject in each part.

___________________

The Audoptic Weblog. It's where the magic happens.

kiswa

kiswa

Yeah, kiswa.
Status: Offline!

You know, that's not a bad idea... I'll have to rename this one Part 1 so I can make a Part 2, etc. Smile

I do want to at least add the bit about the technically non-semantic 'semantic markup' example... so I guess I'll just do that for now, and start coming up with something about DOCTYPE and it's importance.

___________________

www.kiswa.com
My attempt at articles for Neverside CodeBase: Part 1 Part 2 Part 3
(. )v( ) <- The Webstandards Owl

kiswa

kiswa

Yeah, kiswa.
Status: Offline!

Okay, so next is styling semantic markup and using doctype appropriately. Any other topics that you think would be good to cover within this subject?

*** Man, I've edited the crap out of that now. I hope it's okay to stand on its own the way it is. Now, I have to start thinking about Article 2!

___________________

www.kiswa.com
My attempt at articles for Neverside CodeBase: Part 1 Part 2 Part 3
(. )v( ) <- The Webstandards Owl

Last edited by kiswa, May 25th, 2005 07:56 PM (Edited 2 times)

Gil

Gil

Semantics Whore
Status: Offline!

Great article!

These articles will provide a great resource on the new codebase. It reminds me that I was going to write some too...

I skim-read it for now, since I haven't got much time, I'll try to read it in-depth tommorow...

kiswa

kiswa

Yeah, kiswa.
Status: Offline!

Locke... what did you edit in this article? It says you edited it, but I can't figure out where. Would you let me know?

___________________

www.kiswa.com
My attempt at articles for Neverside CodeBase: Part 1 Part 2 Part 3
(. )v( ) <- The Webstandards Owl

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.02 seconds.