CSS

TORRENT


CSS

fullform: cascading style sheets

Extention of cascading style sheets is .css

Purpose:

* Add new looks.

* Restyle a web site.

* Use the “style” on any web page.

Benefits of CSS

* We can change the appearance of entire document by adjusting a few rules

* Style sheets can be applied to multiple documents

* Pages and sites are easier to maintain

* Style sheets can address multiple user

* Documents download faster

There are three ways to include syles in documents.

* Inline styles

* Document-level or internal styles

* External Style sheets

Inline styles

# A style that is specified within the body of any html tag as an attribute of that tag

# The value of style attribute takes a semi-colon separated list of style rules.

Example

Result

Welcome

Document-level or internal styles

# A collection of style rules enclosed in <style> tags in the header of the document.

Example

Result

Welcome

External Style sheets

# Write codes in a seprate document and save as style.css called style sheet, after that link the style sheet to the html file inside the head tag.

Example

css code:

p {
    font-size:1.2em; 
    font-weight: 500; 
    color: red;
}

html code:

Result

Welcome

#Now we learn css with Document-level or internal styles. We can write css codes and html codes seprately.

css selector: a string which defines the element the style rule is being applied to

selector {style declarations go here}
or
selector {property:value}
or
html tag {css property:value}

css class and id

class

#It is possible to give an html element multiple looks with css class.

#We can do different types of formats for a single html tag with the use of class.

Example#without class

Result

Welcome

Welcome

Welcome

Welcome

# here all p tag have same properties, If we want to give diffrent properties to different p tag. Then, we will use class.

# class denoted with (.) dot.

Example#with class

Result

Welcome

Welcome

Welcome

Welcome

Example#with class

Result

Welcome

Welcome

Welcome

Welcome

id

id : a unique identifier to an element.

id followed by a # (hash),

one id can use only one time in a document.

Example

Result

Welcome

css Background

Example

Result

Welcome

Welcome