Understanding Internet Explorer conditional comments

by David Alfaro 7. October 2008 08:17

What are we facing?

There are not a universal implementation of all CSS selectors across all browsers. This page from Centricle shows a neat matrix of OS/browsers against supported selectors. Particularly, I would like to treat the differences between Internet Explorer browsers. Is there a way to deal the style of my site in different ways across different versions of IE?

The Solution

There at least two solutions, but take them cautiously.

First solution: browser detection via JavaScript by querying three properties of the “BrowserDetect” object. You can detect which browser is visiting your page, not just between versions of IE. This solution is highly controversial as you can’t entirely trust the “BrowserDetect” object and may be not implemented at all.

Second solution: the Internet Explorer conditional comments are a way to deal with it. It is specific for IE browsers. The good thing is that it doesn’t break the rendering of other browsers as they are just comments.

So for example:

  <!-- [if gte IE 6]
  <style type="text/css">
       @import ("ie6up.css");
  </style>
  -->

It will load the file “ie6up.css” if the IE browser is version is 6 or greater. Any other browser will ignore it as a comment. The caveat is that such style manipulation should be at CSS file level, not in the HTML file. That puts a maintainability cost on it. Again, take it cautiously.

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ie | hacks

Make your site's style easy to modify by users

by David Alfaro 6. October 2008 11:48

What are we facing

Users may use a customized style to see your web page. That’s true for Firefox and Internet Explorer, and it’s a powerful tool for users to survive an inaccessible site. How do you make users' life easier when they customized your site's style?

The Solution

You can do it by setting a “id” attribute to the “body” element. That “id” attribute must not be used by you, but it may be used by any user to customize how your page is displayed in his/her browser. Using appropriated rules and taking advantage of the high hierarchy of the “body”, users can restyle your site at their will.

For instance, if you add the attribute “ id=’aggiornosite’ ” to element “body” the user could do something like:

#aggiornosite h1 {
    font-family: Impact, sans-serif;
  } 
That's a heading 1 style just for your site!!

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

css | accessibility

Navigation bar using list elements instead of table elements

by David Alfaro 6. October 2008 10:04

What are we facing?

You want a navigation bar that degrades gracefully on text based browsers. You will also want to have a navigation bar constructed with the correct elements to express the closest semantics to a “Navigation Bar”.

The Solution

The most currently recommended way to express Navigation Bars is using list elements. Semantically, navigation bars are simple lists of links to interest points of the site, that is, is just one dimension, it doesn’t justify the use of table elements. Tables are meant for data tabulation. Besides, tables are not friendly with text based browsers.

If you take a look at the source of this site’s Navigation Bar you will see something like:

          <ul>
                 <li><a href="http://www.aggiorno.com/default.aspx">home</a></li>
                 <li><a href="http://www.aggiorno.com/about-aggiorno.aspx">products</a></li>
                 <li><a href="http://www.aggiorno.com/try.aspx">download</a></li>
                 <li><a href="http://www.aggiorno.com/learn.aspx">aggiornings</a></li>
                 <li><a class="redlink" href="http://www.aggiorno.com/blog">blog</a></li>
                 <li><a href="http://www.aggiorno.com/contact.aspx">contact</a></li>
          </ul>

Using CSS magic, you can disable bullets, reveal content for browsers supporting CSS and hide content for those text based browsers.

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

css | seo | idea | accessibility

Get accessible pages by replacing text with Background-Image

by David Alfaro 6. October 2008 02:35

What are we facing?

More often than not, you come up with a beautiful title design based on a font inspired by Dali's most wildest dream. Out of the blue, somebody tells you that you can't go ahead because that font may exist only in your computer, and of course in the hypothetical Dali's computer. Your mom didn't raise a fool, so you just convert the title to image, and now everybody can see it. Think twice, text based browsers (blind users do use them) can't. No problem, just add an alternate text. Not so fast, for search engines “hx” (header) and “title” elements have more SEO relevance than “alt” (alternate text) attributes, it’s just about semantic best practices.  There must be a way to let your artistic spirit be expressed, life can't be that bad.

The Solution

Wait a minute. Is not the header (just above) in font Shelley Allegro? Yes, it is. The immense majority of the computers don't have it, so I did an image of it. But if you see this post using a text based browser like Lynx, or Firefox Accessibility Extension, you will be able to see "The Solution" in plain text. It is “h2” header element. How come? Take a look at the source code.

You will  see this:

<h2 class="firh2">
	<span class="firspan">The Solution</span>
</h2>

Let's introduce the Fahrner Image Replacement method. In this post you will see the basics of that clever method. By having the text of the “h2” inside a “span” element, you can play with styles a little bit. For those having styles and images, the following  CSS will show the image we want:

 .firh2
 {
       background-image: url( "fir-the-solution.gif" );    
background-repeat: no-repeat;    
height: 31px; } .firspan
{
      display:none; }       

The "firh2" id will set image I want as the background of the header, without repetition of it and with the actual size of the image to avoid stretching. The “firspan” will hide the the text of “span”.

For those text based browsers, neither styles nor images are loaded, so the “span” content is displayed. 

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

accessibility | css | idea | seo

Resetting styles for coping with cross browsing differences

by David Alfaro 3. October 2008 08:42

What are we facing?

The war of browsers is a never ending story. With Chrome as a new player in the browsing scene, how do you get sure your website is consistently rendered across multiple browsers? How do I get there?

The Solution

This topic is hot and the cornerstone of having a site accessible. The Central Office of Information of UK will tell you that “conforming to web standards such as XHTML and CSS are more likely to work well across a wide range of browsers”. So obviously, moving your site to web standards will take you on the right path. However, as Rick Strahl states: “even with XHTML there are still major differences between different browsers and how they set their default settings for various CSS tags.”

Oops, and now? Given such lack of communication/definition of standards between browsers in that level, a nifty workaround exists: Browser reset. As Rick Strahl again clearly explains, “A browser reset is meant to reset the browser’s CSS setting to a common default value set. Basically each browser has slightly different base settings mostly for margins, padding, borders etc. as well as many other settings that can affect browser rendering slightly and often results in the little inconsistencies […]. The reset effectively is used to reset the browser to a common baseline, upon which any further CSS settings are based.” 

Brilliant!

Just adding this line (assuming you already have the reset.css file):

<link rel="stylesheet" type="text/css" href="reset.css" />

And now you are able built style upon that resetting, and voila! it will rendered consistently on all browsers.

Where do I find a reset file? You will find some interesting options:

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

css | standards | accessibility

How to prevent Google from indexing some pages of my site?

by David Alfaro 3. October 2008 03:00

What are we facing?

There are circumstances when I want to tell Googlebot to ignore some URLs of my site. For instance, Google lists the cases when Googlebot may unnecessarily consumes excessive broadband:

  • Additive filtering of a set of items.
  • Dynamic generation of documents.
  • Problematic parameters in the URL.
  • Sorting parameters.
  • Irrelevant parameters in the URL, such as referral parameters.
  • Calendar issues.
  • Broken relative links.
How do it prevent Google from indexing those URLs?

The Solution

Besides best practices to avoid those behaviors, you can make use of the robots.txt file in the root of your site. The Wikipedia explains that such file must follow the Robots Exclusion Protocol which" is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a website which is otherwise publicly viewable".

The next is an example that tells all crawlers not to enter four directories of a website:

 User-agent: *
 Disallow: /cgi-bin/
 Disallow: /images/
 Disallow: /tmp/
 Disallow: /private   

Another alternative is using the META tag for telling the robots not to index any specific page, like this:

  <html>
  <head>
  <title>...</title>
  <META NAME="ROBOTS" CONTENT="NOINDEX">
  </head>

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

seo

Rewrite engine for URLs and SEO

by David Alfaro 2. October 2008 11:11

What are we facing?

Rating higher for SEO is also achieved by having a simple URL structure. Any URL should be intelligible for humans, if you accomplish so, you will make it really understandable to Googlebot. Complex URL by using multiple parameters may cause an abuse of broadband by crawlers. How can I have simpler URL structures?

Solution

You have to rewrite the URL at server level and to use Regular Expressions to identify the original URL structure and to construct the desired one. In the case of Apache server, you will need the mod_rewrite module installed. In other side of the street, IIS 7.0 supports rewriting by HttpModules. Take a look at

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

seo

CROSSLINKER as a data base of links

by David Alfaro 1. October 2008 09:59

What are we facing?

I am a webmaster of a corporate site, I have always to remember inserting a corresponding link in every mention of product X,Y and Z. That is, X phrase or word has always link Lx, Y phrase or word has always Ly and so on. The problem is that it is tough having such control always; I may forget a couple of references.

Solution

A possible to do it is having an automated tool that learns the relationships between words or phrases and their corresponding links as you build them and also it can learn for existing websites. When you finish your page or website, you apply this tool to convert to links the words or phrases the tool link in the way the tool earned.

Some external references

If you want to know about cross-linking best practices, take a look at these links:

Server location, cross-linking, and Web 2.0 technology thoughts

Hub & Spoke: How to Cross-Link Your Websites

Currently rated 4.3 by 3 people

  • Currently 4.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

idea

Detecting unused CSS selectors

by David Alfaro 1. October 2008 09:01

What are we facing?

Anyone working in large web projects in collaboration with many people at the same time will see the consecuences of many hands on style files. May selectors and classes come and go while developing and testing. After a while, you will easily see style files that become untouchable: you don't know which classes or selectors are being used or not. The same uncertainty creeps in when you maintain someone else's site.

The Solution

There are several solutions out there about detecting unused classes and selectors, I will list the most popular:

  • Dust-Me Selectors: "Dust-Me Selectors is a Firefox extension (for v1.5 or later) that finds unused CSS selectors. It extracts all the selectors from all the stylesheets on the page you're viewing, then analyzes that page to see which of those selectors are not used. The data is then stored so that when testing subsequent pages, selectors can be crossed off the list as they're encountered"
  • TopStyle 3.5 for Windows: It has a "orphan classes report".
  • CSS Redundancy Checker: It's a free online service. "Use this tool to find CSS selectors that aren't used by any of your HTML files and may be redundant".
  • Unused CSS Cleaner: "This tool helps you find orphaned CSS styles (Classes, IDs) that are present in the stylesheets but not used in the web pages".
  • IntelliJ IDEA - HTML/XHTML/CSS Editor: "CSS on-the-fly validation: Unused CSS class definitions".
  • Style Studio CSS Editor: It has a "Selector Report that detect Unused CSS CLASSes/IDs".
  • Expression Web's CSS Reports: The CSS reporting feature is a way to examine unused CSS styles that need to be cleaned up".

Some external references

Currently rated 4.4 by 5 people

  • Currently 4.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

standards | css

Embedding XHTML compliant Youtube videos

by David Alfaro 1. October 2008 05:16

What are we facing?

Youtube provides a code for embedding any video in my page, however the such a code is not XHTML 1.0 compliant. What is the generic way of making any Youtube video XHTML 1.0 compliant?

The Solution

The code given by Youtube for any video to be embedded in your page has the following format:

<object width="A" height="B">
   <param name="movie" value="C"></param>
   <embed src="C" type="application/x-shockwave-flash" width="A" height="B"></embed>
</object> 

Where A is the width, B is the height and C is the url's video source.

The XHTML 1.0 friendly version of that is in the following format:

<object type="application/x-shockwave-flash" style="width: Apx; height: Bpx;" data="C"> 
   <param name="movie" value="C" />
</object>

Is the display the same? Take a look (you can also see the source code in your browser)

Displaying with Youtube video code

Displaying with XHTML 1.0 compliant code

Don't you agree that a automated tool to do this would be a great idea? There are many scenarios when this is a "nice to have"

Some external references

Embedding YouTube Videos as Valid XHTML 1.0 of Bernie Zimmermann

YOUTUBE XHTML EMBED of Paimonia

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

standards

About Aggiorno KC

Aggiorno RSS Feeds As Web developers, we are always hunting for pieces of wisdom spread all over the Web, by friends, by books, or both. Normally it requires time and effort to search and locate that wisdom and then even more to implement it. Knowledge Capsules provide you with a consolidated place to find all the specific pieces of code and advice you are commonly looking for, all provided by fellow Web developers.

IE8 Compatibility Wizard

Automatically upgrades your website to render correctly in IE8!

Internet Explorer 8 Compatibility Wizard

Get it today!


ArtinSoft Corporation ArtinSoft is Microsoft Certified Partner ISV/Software Solutions and Microsft Visual Studio Partner

With over fifteen years of experience, ArtinSoft has proven to be a key player in software evolution, by allowing customers from all over the world to ensure business continuity and compliance through software migration solutions and developer tools created upon principles of artificial intelligence. At present time, ArtinSoft Corporation remains a private firm in constant growth through a strategic partner network. Read More...