Friday, September 19, 2014

What are CSS Selectors?

CSS Selectors
CSS  selectors are used to "select" elements/tags on an HTML page to style them. The properties are set in a rule set, you know every rule set is combination of CSS selector and properties block. These properties only apply to the elements mentioned in rule set.


Types of CSS Selectors
Following are the types of CSSS Selectors:-
  • Universal Selector
  • Type Selector
  • Class Selector
  • ID Selector
  • Attribute Selector

Thursday, September 18, 2014

Where can CSS codes be placed in a web page?


Where can CSS codes be placed in a web page?
CSS codes can be placed in couple of ways:
(a).Current HTML Page
(b). External file saved with .css extension
(a).Current HTML page.
There are three important places where CSS code can be easily placed inside current HTML page.
  1. It can be inserted  in the HEAD section

    <html>
    <head>
    <title>Page title goes here</title>


    <style type="text/css">
    selector {
      property1:value;
     property2:value;
    }
    </style>

    </head>
    <body>
    ... Page cotent ...
    </body>
    </html>

2.In a <style> tag 
<style type="text/css">

selector {
  property1:value;
 property2:value;
}
</style>

3.Inside the HTML element, with "style" attribute.


<p style="color:blue;font-weight:bold;">This paragraph has used style attribute 
of tag p.</p>

(b). External file saved with .css extension.

When the CSS code is written in an external file, the CSS code is written in the same manner, but without the <style> tag.

Rule Set of CSS file


CSS-based style sheets contain  list of statements , this list of statements is also called Rule Set.
  A rule set in in fact combination of a selector and a declaration block. This block usually has an opening and closing braces i.e.’{‘ and ‘}’  like c language.  The block can have style properties and their values.