Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Doctype considerations


azpro

Recommended Posts

Hi all,

 

I searched the forum and other sources but could not find a conclusive answer for best practice on which Doctype best to use for osC 2.3.3.3. Off course W3 validation is essential and after changing doctype to

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

we see quite some errors for our products_description field containing a lot of unordened lists without proper XHTML. For example lacking closing </li> tags and Capitalized tags, eg:

<UL>

<li>

</ul>

 

In the past we used the native osC doctype:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

which is more loose on things like unordened list and capitalized tags.

 

Off course it is possible to write a function with preg_replace <UL> to <ul> - <br> to <br /> and (allthough quite complex using some xml-coding) to close off <li> with proper </li>.But on testing I concluded it may be NOT the way to go forward (because of inconsistent products_description). Since we have over 25.000 products it is impossible to check all. Therfore I consider to go back to <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">.

 

I like to stay as close as possible to core oSC-code and would prefer the XHTML doctype. So any considerations on the Doctype issue? Feedback and help much appreciated.

 

Regards!

Link to comment
Share on other sites

if its the products description - then any tags in the products description would have been added by yourself - so it would be a good idea for you to check your code and make the necessary corrections and close any open tags, well thats if you want to keep as close as possible to the core osC code

 

The default out the box installation of osCommerce validates 100% correctly as an XHTML 1.0 Transitional . Now would be a good time to brush up on your xhtml coding standards

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

Thank you Melanie for your reply! As for your remark about products_description, off course we added these tags ...

 

But I am looking for (technical) pro's and con's using XHTML over the older HTML Doctype.

 

Regards!

Link to comment
Share on other sites

basically - there are no real benefits for your visitors to your web site but, here are some reason why a switch from html 4.01 to xhtml would be a good thing.

 

XML syntax rules are far more rigorous than HTML. As a result, XHTML makes authors work more precisely, having to address issues such as:

  1. all elements and attribute names must appear in lower case
  2. all attribute values must be quoted
  3. non-Empty Elements require a closing tag
  4. empty elements are terminated using a space and a trailing slash
  5. no attribute minimization is allowed
  6. in strict XHTML, all inline elements must be contained in a block element
  7. XHTML is XSL ready
  8. The syntax rules defined by XML are far more consistent than those found in HTML

In HTML, case, quotes, termination of many elements and uncontained elements are allowed and commonplace. The margin for errors in HTML is much broader than in XHTML, where the rules are very clear. As a result, XHTML is easier to author and to maintain, since the structure is more apparent and problem syntax is easier to spot.

 

For a Web designer, starting to use XHTML 1.0 will be helpful in some circumstances and will certainly help you to smoothly negotiate the future. XHTML 1.0 gives a wonderful opportunity to learn about XML languages and their possibilities without having to learn new semantics because you’re working with familiar tags and attributes.

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

Note that HTML 5 has rolled back many of the XHTML restrictions listed above. XHTML is now considered to be a side-trip in the march of progress for HTML! Nevertheless, XHTML style is still legal in HTML 5, and is probably still a good idea, both for the rigor (and correctness checking), and leaving things open for use with XSL, etc.

Link to comment
Share on other sites

Thanks for replies and remarks!

 

I decided to keep the osC 2.3.3. Doctype:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" <?php echo HTML_PARAMS; ?>>

 

Problems with validation of XHTML (while keeping a bullet-list appearance) were solved with native PHP functions:

 

<?php

$products_description = str_replace('<li>', '• ', $product_info['products_description']);

echo nl2br(strip_tags( stripslashes($products_description),'<b><b/>'), true);

?>

 

Hope this may help other people.

 

Regards!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...