Archive for the ‘Browsers’ Category

Make HTML5 code work in most browsers

Monday, February 16th, 2009

One thing I can’t wait for in HTML5 is the new structural tags, such as <header> and <nav>.  What I didn’t know, is that with a little work you can actually use them right now.  Because most browsers have support for unknown tags, you can just use them as normal.  There are a couple issues, but they can be addressed with a few lines of code.  The first is that all unknown elements are treated as inline, so you have to style them.  The second is that unknown elements aren’t added the the DOM correctly in MSIE, but a quick document.createElement will fix that.  Here’s a code snippet that shows you how to put it all together:


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML5</title>
<style type="text/css">
  section, header, footer, nav, article {
    display: block;
  }
</style>

<!--[if IE]>
<script type="text/javascript">
function(){
  var e = ["section","header","footer","nav","article"];
  var i = e.length;
  while (i--) { document.createElement(e[i]) };
}();
</script>
<![endif]-->

</head>

I’ve only enabled a few basic tags.  For a minified javascript file that enables them all, check out Remy Sharp’s HTML5 enabling script.  You’ll also have to style all the elements you plan on using.

I haven’t tested this technique a whole lot, and my guess is it could introduce other issues (for example, some browsers would handle it in “almost standards” mode), but it’s worth playing with.

Mozilla, Accessibility, and Target

Friday, October 20th, 2006

Last week was the Mozilla Accessibility Summit in Cambridge, MA. Shane Anderson gives a general overview, with links to Mark Pilgrim’s more detailed account of the presentations. If you’re getting the sense that Firefox is positioning itself as a sort of vanguard to advance and cultivate the cause of web accessibility, you would be correct.

As an update of Tim’s earlier post (regarding Target being sued by the National Federation of the Blind for failing to provide accessible website content), last month a California federal judge decided not to dismiss a discrimination case against retailer Target Corp. This opens the door to all Internet-related Americans with Disabilities claims, proving that websites fall under the category of “physical places of accommodation.” Target had filed a motion to dismiss the case on the premise that ADA laws don’t apply to Web sites, going so far as to suggest that such laws violate the Commerce Clause of the U.S. Constitution.

Internet Explorer 7 and Web Standards (The Ongoing Saga)

Monday, August 28th, 2006

Microsoft’s Chris Wilson, the Group Program Manager for IE, is interviewed by ZDNet regarding the issue of whether Microsoft’s latest web browser IE7 is - and will be - CSS and Web standards compliant. Some people are still skeptical.

Smuggling Proprietary CSS and the Validity of the Validator

Thursday, February 9th, 2006

Will makes an interesting point in his blog post about using browser-specific CSS and still having webpages validate. His quandry:

Have you ever been tempted to use a CSS property such as -moz-border-radius, but can’t stand the thought of having a page that refuses to validate?

He can’t add it to an external stylesheet through <link>, nor can he use it internally within <style>; if he does, neither will validate.

However, adding the proprietary CSS to a style attribute on an element gets around the problem, since the W3C HTML validator does not check the validity of CSS within style attributes.

Observe; the code below uses the -moz-border-radius, but the resulting HTML will still validate.

The code:

<div style="padding: 0.25em 0.5em;
   border: 2px solid #605953;
   -moz-border-radius: 25px;
   background: #f1efec;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</div>

The result:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

On the one hand, it’s a neat trick (not necessarily a hack) that gets around the validator and allows a developer to use non-standard styles on his page. On the other hand, that’s exactly it: it’s non-standard; and I agree whole-heartedly with Will, who so colorfully elucidates:

Yeah, it is kind of an ugly method, but you shouldn’t care since if you’re going to use it, right? After all, depending on proprietary CSS is like depending on a rotten wood catwalk over a tank full of the proverbial kind of bovine fecal matter.

All of the above got my brain thinking about validation and standards.

The W3C Validators are not the end-all-be-all definitive sources for creating standards-based websites. As Will (and now I) have successfully pointed out, proprietary (and, in most cases, non-standard, non-valid) code can be “smuggled” into a website and can trick the validators into thinking the code is perfectly valid.

The point is that standards are about much more than just validation. They are also about what works for you. You may have a certain work ethic, i.e. a personal standard, that no one else has heard of, let alone uses for himself. Does that make your work ethic any less valid? Pft. Of course not.

Any Joe with an Internet connection and a text editor can create a page that validates and claim it’s “standards-compliant”. As Mike Davidson wrote almost twenty months ago:

Web standards are about all the processes involved in publishing information over IP. [...] Just because you can validate your code doesn’t mean you are better than anybody else. Heck, it doesn’t even necessarily mean you write better code than anybody else. [...] Spewing validation manifestos on message boards isn’t going to show you how to listen, negotiate, compromise, and execute.

Developers Recommended to Support IE Rivals

Wednesday, January 25th, 2006

Web developers have been told to ensure that the sites they build are operable with browsers which rival Internet Explorer. This includes open-source heroes Firefox and Apple’s Safari. Deri Jones of SciVisum explains their reasoning and has the XiTI metrics to back it up:

Jones advised web developers to develop code around the W3C’s Cascading Style Sheets 2 specification, which simplifies site development by separating content and presentation, and makes sites more accessible to disabled people. “Those that stick to standards have much more reliable, stable and fast web sites,” Jones argued. “They should keep it simple, and [taking into consideration] accessibility issues also improves the performance of web sites.”