• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Why Validate?

As much as you try to pay attention to details, it is easy for small errors to sneak into your style sheet. Validating your style sheet and HTML file can serve as a form of proofreading, catching small errors and typos in your code that are otherwise difficult to see or notice. A common example of a CSS error, for instance, is forgetting to specify a measuring unit. This is easy to do, because in HTML, numerical measures specify pixels by default, while in CSS you have to specifically identify which measuring system you're referencing (pixels, ems, percentages, centimeters, and so on). Other very common errors include using a regular parenthesis when you need to use a squiggly parenthesis or using a colon when you need to use a semi-colon. Validating your style sheet also catches any property/value mismatches—you might think that a property takes a particular value, for instance, but it doesn't.

Validating your style sheet can also help make sure that you're following best practices when creating your style sheets. For instance, just specifying a foreground color for elements, without also specifying a background color, doesn't generate any errors, but does generate warnings when you validate your style sheet. That's because a user might be using a user style sheet that specifies foreground and background colors for certain elements—if you only specify a foreground color, you might end up with dark blue text against a black background, for instance. At minimum, you should declare a transparent background color (background: transparent), which lets any underlying background color that you've set for the parent element shine through.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint