Archives for the month of: August, 2010

You see it a lot, but sometimes it can do more harm than good. Click here, while descriptive can also be elusive at the same time when it comes to search engine optimization. As early as 2001, the Quality Assurance Interest Group at  W3C was recommending that you do not use click here as a link indicator. Consider the following links…

Each link would take to you the same place and imply that they are links denoted by the underlined text. As a general rule, most people understand that underlined text is a link and do NOT need to be instructed to click here. The difference is that the second link will now associate the URL with the action Purchase SuperWidget instead of Click Here. While I am on the subject, you should also refrain from underlining text in your website if it is not a hyper-link, it can be confusing to your reader as they might think it is a link.

With the importance of search optimization these days, every little bit you can do will go a long way.

Using the Modulus PHP Arithmetic Operator, you can easily assign an alternate class to a repeated element. Depending on whether a number is odd or even, you could choose which color to make each row by assigning the css style selector to the repeated tag.

Example PHP Function

This function will output the text string “ alt“. It is best used inside the class attribute of your HTML element if the number passed to this function is an even number.

function doAlt($n) {
    if ($n % 2) {
        echo(' alt');
    }
}

Example HTML Markup

for ($i = 0; $i <= 4; $i++)	{
	echo '<div class="row'.doAlt($i).'">Row '.$i.'</div>';
}

Example CSS Styles

.row {
background-color:#000000;
color:#FFFFFF;
width:300px;
}

.alt {
background-color:#1B2426;
}

Example Output

<div class="row">Row 0</div>
<div class="row alt">Row 1</div>
<div class="row">Row 2</div>
<div class="row alt">Row 3</div>
<div class="row">Row 4</div>