I'm a web developer who works with HTML, PHP, CSS, ExpressionEngine, Javascript, jQuery, MySQL, SEO and UI/UX design. Always looking to learn new web related stuff, and a bit of a PC gamer. You can also find me on Twitter and LinkedIn.

Posts Tagged: html

Text

Validate your code.

Why?

Well, the W3C can tell you why you should validate your code, and they do a much better job of telling you what you need to know than I would. But I will list the basic reasons if you can’t be bothered to click the link:

  • Validation used as a debugging tool
  • Future-proof quality checking
  • Helps teach good practices
  • Gives a sign of professionalism

How?

There’s a great little Firefox add-on called HTML Tidy. In conjunction with viewing the source of a page, you can easily track down invalid code to set it back on the straight and narrow.

You can also use the online W3c HTML Validation Service and the online W3c CSS Validation Service if you develop using other browsers.

Text

Just a quick one.

I’ve recently had the need to use a submit button in a web form, with no CSS styling and without using an image (the client wanted it to look like a standard form button), which had to have the value text of the button on 2 sperate lines.

Using the <br /> tag didn’t work, and neither did the use of ‘/n’. So after a bit of digging I found an ascii code which worked: &#10;

Here’s an example of the code in use:

<input type="submit" value="Submit&#10;Query" />

Text

Comment your code.

It doesn’t really matter what code you’re writing, whether it’s HTML, PHP, CSS, Javascript or anything else, commenting your code can become very important.

There are a number of reasons why we should look to comment our code;

  1. If someone else has to work with your code, it will help them decipher what the hell is going on.
  2. It can be used to search for a specific block of code by adding key phrases/symbols to search for in the comments.
  3. If you haven’t worked with a piece of code for a long time, it can refresh your memory, saving you having to work it all out again.
  4. Other people can learn from what you’ve done.

Number 4 on that list is my favourite. I’ve learnt a great many things by seeing something I like on the web, checking out the code and having a go at building it myself. Help out your fellow developers, let them learn from your work.

Text

When to use tables for layout.

This post would be much shorter if I could just say NEVER!

However, there are two instances when you should use them. One is the correct reason for using tables, the other is unfortunately borne out of necessity.

You should use tables for: tabular data.

The key word there is data. It is to be used when you have information to present that would best be displayed in the form of a spreadsheet.

So, when is it necessary for you to use tables? HTML email newsletters.

For anyone who tries to conform and promote web standards, HTML email newsletters are a horrible trip back in time, like an LSD fuelled Flux Capacitor.

Sorry.

HTML email newsletters are the bane of the purist web developer for more than just this reason, but that’s another post for another time.

So, there we go, use tables for displaying data on web pages, and for layout ONLY in an HTML email newsletter.

Otherwise? NEVER.