One of the most common questions I get asked related to beginning HTML and CSS is “Why isn’t this working?” Unfortunately, I can’t look at everyone’s individual project or I wouldn’t have time to do my own projects, but now and I then I do take a look if it looks like it will be something fast and one of the most common errors I see is special characters in the text. This often happens when you cut and paste from a program like Microsoft Word, which uses special characters for characters like quotes. In fact, that was exactly the case today, when I received a question from a reader who was stuck on the very first example from Head First HTML with CSS & XHTML; his CSS just wasn’t working and he was incredibly frustrated, understandably so! When I loaded his HTML file and took a look at the source using my browser, I noticed that his opening style tag had special characters around the type attribute:
This type of error is hard to catch, especially for beginners. In your editor, you’re seeing quotes, so you never know there’s a problem unless you “view source” using your browser and see the special characters in the source window (which displays plain text).
So, two tips:
- Make sure your editor is set to plain text so no special characters are inserted into your HTML and CSS
- If you’re having problems, look at the source using the “view source” menu (in Safari, View > Source). This will often uncover problems like special characters that you might not be seeing in your regular editor.
Keep sending your questions; we’ll try to answer them personally or on the blog!