Role Of CSS (Style sheet) in Web Page

Role of CSS

JQuery is based on CSS and searching objects from DOM database can be performed by Class name. To understand the major role of CSS read this page and try to understand the basics given here. This page will help you to understand the logic behind find method of JQuery and I recommend you to please don’t go forward if you are not clear on these basics.

Three ways to Apply CSS

  • You can apply CSS on any control by using Control ID.  For example, if you want to apply something on div1 so you can write #div1{} in your CSS
  • You can apply CSS on any control by class Name. for example, if you want to apply something on all the controls having a class MyDiv so you can write. MyDiv{} in your CSS
  • You can apply CSS on any control by Tag Name. for example, if you want to apply something on all the div controls on your page so you can write Div{} in your CSS

Nested Classes

  • You can provide class name to the parent object and create styles for child objects.
  • Same thing can be apply for ID as well for example #headerdiv span {} defines the style for all span elements in the element which has an id headerdiv

Multiple Classes

  • You can apply more than one class to your control. for example, you have two classes one defines the table behavior and another defines the GridView behavior and you want to apply both behaviors on a html table.

Attribute Vs CSS property

  • Every object in DOM has some properties like id, height, width etc7.
  • These properties can be categorized into two groups “Attribute” and “CSS Property”.
  • ID, class, type or any other attribute which defines outside style=”” are called attributes. you can also define any attribute for any control and there is no limit of these attributes.
  • The properties defined within style=”” are called css properties.

 

Leave a Reply

Your email address will not be published. Required fields are marked *