To clarify, the_category() doesn’t pass HTML validation because it outputs a rel="category" attribute which W3C tells me is a big no-no.
I’d still love to hear anyone’s thoughts / opinions on this but I’ve written up some code to replace the_category() with a function that outputs valid code:
The full rundown here.
But essentially, here’s the function:
// Create a function to output valid category links
function the_category_valid() {
$categories = get_the_category();
$separator = ', ';
$output = '';
if($categories){
foreach($categories as $category) {
$output .= '<a href="'.get_category_link($category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
}
echo trim($output, $separator);
}
}
I suppose it could be customized even further to allow for all of the various functionality of WordPress’ the_category() but that’s a good start. Feel free to improve!
HTML/CSS validation is not strictly enforced, and has not been for some time. HTML validation is too ethereal, and not nearly important enough, to warrant strict enforcement.
HTML/CSS validation is only enforced so far as: don’t break anything with your markup, such as with improperly nested tags/unclosed containers/etc.
Hey thanks for the reply, Chip, always very appreciated to hear back from someone other than myself. 🙂
I absolutely love these resources by the way. Makes developing themes for my clients so much easier to test and ensure.
I updated to latest WP application. Lost my new post template. Then the site (Godaddy host)went down. Something in WP changed the Godaddy HT access file. We had to rename it to bring the site back up. Now I get a message from Google that they cannot access the robots.txt file.. I installed a WP site map plugin but cannot access the HTML to repair the errors. And of course, NO HELP FROM WP. Im trying to get a management name from San Francisco WP to see why we get no help except from outdated and closed forums. http://www.codeforeblog.com