Simple Code Snippets

Validating Code

When writing HTML, a good practice to get into is making sure that this code is valid. Valid code has a lot of advantages. Your page is more likely to look the same or how you expect it to in more browsers and the browsers will have less trouble dealing with tangled code and old tags.

To check your code you can use the W3C HTML Validator, this will be added to the resource section.

What this validator does is takes a look at the DTD at the top of your page and takes the version of (X)HTML and checks that against a list of standards and rules. What the validator then does is flag up any issues so that they can be fixed.

Creating valid (X)HTML is a great routine to get into. So its worth popping over to the validator and bookmarking it for later use.

Tags: ,

Wednesday, October 29th, 2008 HTML, Simple Code Snippets No Comments

How to add an external stylesheet

With stylesheets becoming the norm in web layout and design, the best way to attach these to your site it externally. This means totally splitting the html from the css. To do this we need 1 link of code that is placed in the head tag <head>, this tag is:

<link rel=”stylesheet” href=”style.css” type=”text/css”/>

All you have to do is use the same code as above and either name your stylesheet to style.css or change the href value to the name of your stylesheet.

Tags: , ,

Tuesday, October 14th, 2008 Simple Code Snippets No Comments