CSS Rules and Selectors

CSS Rules and Selectors

:: "Learn about CSS rules and selectors and how to use them..."

CSS Rules

CSS rules tell your HTML tags HOW to display content in the browser - they manage all your web page presentation.

A CSS rule is basically consists of 2 parts: a selector and a declaration.

Selector

Selector - These start each rule, before the curly bracket. Here is the basic syntax of a CSS selector (bold below) - note that the selector targets a specific HTML element:

selector { property: value; }

For example, if you want to style your large header, h1 to look a certain way you would do something like this:

h1{padding:5px;}

Declaration

Declaration - This is simply the property and the value assigned to the selector. (bold below)

selector{ property: value; }

A thorough knowledge of CSS rules (selectors along with their properties and values) makes web design easier, more interesting for the developer, and sets up an efficient and organized approach to web page building. The key to getting good at CSS is experimenting and practicing - don't be afraid to make mistakes!

*NOTE : all CSS selector, property and value are in lower case, which is the xhtml standard.

CSS selectors are what drive your style sheet. They basically dictate how HTML elements will be displayed such as:

  • h1, h2
  • p
  • div
  • form elements: input, textarea, fieldset, legend
  • many more... were simply learning the basic syntax of a CSS rule at this point.

Understanding CSS rules is key to good CSS coding.

Review the web building process: build web site free

Was this helpful? Leave a comment...

Please leave your comment...name or email is not required. If you leave your email we WILL respect your privacy and not spam you. We may update you occasionally with value added info related to web building, web design, CSS, HTML. Thanks!

Name:
email :
comments :

Comments...