Cascading Style Sheets Part-1
Cascading Style Sheets Part-1
Zahid Javed
More about CSS and different versions
Zahid Javed
1-Compatibility (CSS2 VS CSS3)
Zahid Javed
2- Rounded corners and Gradients
(CSS2 VS CSS3)
Zahid Javed
3- Animation and Text Effects
(CSS2 VS CSS3)
Zahid Javed
4- List (CSS2 VS CSS3)
Zahid Javed
4- Pseudo-Classes (CSS2 VS CSS3)
Zahid Javed
Why you should use CSS?
1- Easy to maintain
To update a change simply change the style file and the elements in all web
Pages will be updated automatically.
Zahid Javed
Why you should use CSS?
Zahid Javed
CSS Syntax
Zahid Javed
Syntax of CSS
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors (Descendant )
Result
Zahid Javed
Types of Selectors (Descendant )
Zahid Javed
Types of Selectors (Descendant )
Types of Selectors
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors (Child)
Zahid Javed
Types of Selectors (Child)
Zahid Javed
Types of Selectors (Child)
Result
Result
Zahid Javed
Types of Selectors (Child)
Types of Selectors
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors
Zahid Javed
Types of Selectors on Tag
Zahid Javed
Types of Selectors (Adjacent Sibling)
Zahid Javed
Types of Selectors (Adjacent Sibling)
Zahid Javed
Types of Selectors (Adjacent Sibling)
Types of Selectors ( General Sibling ~)
Zahid Javed
Types of Selectors (General Sibling ~)
Types of Selectors (Tag’s Attributes)
Zahid Javed
Types of Selectors (Selector: Pseudo-class)
Zahid Javed
https://guinatal.github.io/under
standing-css-combinators/
CSS Combinators
Zahid Javed
CSS Combinators
Zahid Javed
Attribute Starts With Selector
• <p class="line-first-para">First Paragraph</p>
• <p class="second-para">Second Paragraph</p>
• <p class="line-last">Third Paragraph</p>
Zahid Javed
External Style Sheet
• This is the most sought method for applying styles to web pages.
• It is an ideal and ultimate choice when we want to style several web pages. The
style rules are supplied in a separate file called CSS file.
• It is created using notepad and saved with .css extension. This CSS file
exclusively contains the style rules we wish to apply to our web site or a group
of web pages.
Zahid Javed
External Style
Sheet
• Font type or color or anything
like that, we can just edit it in
the CSS file and the change gets
applied wherever it is
applicable. So we can change
the entire look of the web site
by just making change in one
file.
Zahid Javed
Internal Style Sheet
The example for inclusion of internal
style sheet is as follows:-
Inline style sheet
Using the style attribute we can apply the inline styling to a tag. The applied
styling is only applicable to the tag on which it is used. This is not an efficient
approach as we are combining presentation with the content.
Inline styles affect the stand alone property of HTML. In the above example, if
we want to change the text to another color, we have to go to each and every
line & edit the code. This consumes a lot of time & effort.
It is a good idea to avoid inline style sheets whenever and wherever possible.
Zahid Javed
Inline style sheet
CSS can be added to HTML code in 3 ways
Zahid Javed
CSS
The example for
inclusion of internal style
sheet is as follows:-
Order of Priority
CSS Rule
Inline Vs Internal Vs External
Zahid Javed
Reference
https://www.educba.com/css-vs-css3/
Zahid Javed