SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Pseudo
CSS Selectors
Link-related
pseudo class selectors
:link

<a href = “google.com”>unvisited link</a>

/* set default style for unvisited link */
a:link{
      color : blue;
      text-decoration : underline;
}
:visited

<a href = “google.com”>visited link</a>

/* set default style for visited link */
a: visited{
       color : red;
       text-decoration : underline;
}
:active

<a href = “google.com”>visited link</a>

/* set selected state style for a link */
a: active{
      color : red;
}
:hover

<a href = “google.com”>visited link</a>


/* set mouseover style for link */
a: hover{
      color : red;
}
Input & link related
pseudo class selectors
:focus

<input type = “text” name=“user_name”/>

/* onfocus change field background */
input: focus{
     background : red;
}
:target
<a href = “#set”>SET</a>
<div id =“set”>This is set</div>


/* change style of target element */
: target {
      background : red;
}
:enabled | :disabled
<input type = “text” />
<input type = “text” disabled="disabled"/>

Input : enabled { /* change style of enabled element */
     background : red;
}
Input : disabled { /* change style of enabled element */
     background : blue;
}
:checked
<input type = “checkbox” checked="checked"/>
<input type = “radio” checked="checked" />
<input type = “checkbox” checked="checked"/>

/* change style of checked element */
Input : checked{
     width : 200px;
}
Position/Number-based
 pseudo class selectors
:root

/* SELECT ROOT Document Element */
:root{
      background : red;
}
/* Will select the <html> element*/
:first-child | :last-child
<ul>
        <li>A</li> <li>B</li> <li>C</li>
</ul>

ul li : first-child {    /* select first item*/
         background : blue;
}
ul li : last-child {     /* select last item*/
         background : red;
}
:nth-child(N) | :nth-last-child(N)
<ul>
        <li>A</li> <li>B</li> <li>C</li>
</ul>

ul li : nth-child(N/odd|even) {
        background : blue;
}
ul li:nth-last-child(N/odd|even){
        background : red;
}
:first-of-type | :last-of-type
<div>
     <p>A</p> <span>B</span> <p>C</p>
</div>

div p : first-of-type { /* select first item of type p */
       background : blue;
}
div p : last-of-type { /* select last item of type p*/
       background : red;
}
:nth-of-type(N) | :nth-last-of-type(N)
<div>
     <p>A</p> <span>B</span> <p>C</p>
</div>

div p : nth-of-type(N/odd|event){
      background : blue;
}
div p : nth-of-type(N/odd|event){
      background : red;
}
:only-of-type
<div>
     <p>A</p> <span>B</span> <p>C</p>
</div>


/* select only one element from type span */
div span : only-of-type {
      background : blue;
}
Relational
pseudo class selectors
:not(S)
<div class=“element”></div>
<span class=“element”></span>
<p class=“element”></p>


/* select all non span elements */
.element : not(span) {
      background : blue;
}
:empty
<p></p> <!-- select first item -->
<p>Content</p>


/* select the empty p element */
p : empty {
      background : blue;
}
Text-related
pseudo class selectors / elements
:first-letter | :first-line
<p> Lorem ipsum dolor si amet </p>

p : first-letter { /* change first letter of text style*/
        font-size : 25px;
        font-weight : bold
}
p : firs-line { /* change first line of text style*/
        text-decoration : underline
}
Content-related
pseudo "elements"
:before | :after
<span> Some text </span>


span : before { /* add extra content before span */
      content : “ … ”
}
span : after { /* add extra content before span */
      content : “ … ”
}

Weitere ähnliche Inhalte

Was ist angesagt? (20)

CSS3 and jQuery
CSS3 and jQueryCSS3 and jQuery
CSS3 and jQuery
 
Xml p5 Lecture Notes
Xml p5 Lecture NotesXml p5 Lecture Notes
Xml p5 Lecture Notes
 
Xml intro1
Xml intro1Xml intro1
Xml intro1
 
Html5 appunti.0
Html5   appunti.0Html5   appunti.0
Html5 appunti.0
 
XML XSLT
XML XSLTXML XSLT
XML XSLT
 
Xml
Xml Xml
Xml
 
Intro to java script
Intro to java scriptIntro to java script
Intro to java script
 
Xslt tutorial
Xslt tutorialXslt tutorial
Xslt tutorial
 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
 
Xml
Xml Xml
Xml
 
json
jsonjson
json
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
PHP - Introduction to PHP Forms
PHP - Introduction to PHP FormsPHP - Introduction to PHP Forms
PHP - Introduction to PHP Forms
 
Introduction to MySQL in PHP
Introduction to MySQL in PHPIntroduction to MySQL in PHP
Introduction to MySQL in PHP
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Xml Lecture Notes
Xml Lecture NotesXml Lecture Notes
Xml Lecture Notes
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
XMLT
XMLTXMLT
XMLT
 
Database design and error handling
Database design and error handlingDatabase design and error handling
Database design and error handling
 
CSS
CSSCSS
CSS
 

Andere mochten auch (10)

CSS Pseudo Classes
CSS Pseudo ClassesCSS Pseudo Classes
CSS Pseudo Classes
 
JDBC
JDBCJDBC
JDBC
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
 
Casc Style Sheets Ii
Casc Style Sheets IiCasc Style Sheets Ii
Casc Style Sheets Ii
 
Week 12 CSS - Review from last week
Week 12 CSS - Review from last weekWeek 12 CSS - Review from last week
Week 12 CSS - Review from last week
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Agile Development | Agile Process Models
Agile Development | Agile Process ModelsAgile Development | Agile Process Models
Agile Development | Agile Process Models
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 

Ähnlich wie Pseudo CSS Selectors

Ähnlich wie Pseudo CSS Selectors (20)

HTML and CSS part 2
HTML and CSS part 2HTML and CSS part 2
HTML and CSS part 2
 
CSS3 and Selectors
CSS3 and SelectorsCSS3 and Selectors
CSS3 and Selectors
 
Types of Selectors (HTML)
Types of Selectors (HTML)Types of Selectors (HTML)
Types of Selectors (HTML)
 
Css Selectors
Css SelectorsCss Selectors
Css Selectors
 
CSS Selector
CSS SelectorCSS Selector
CSS Selector
 
Html advance
Html advanceHtml advance
Html advance
 
HTML-Advance.pptx
HTML-Advance.pptxHTML-Advance.pptx
HTML-Advance.pptx
 
Css(handbook)
Css(handbook)Css(handbook)
Css(handbook)
 
Css1
Css1Css1
Css1
 
Exam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NETExam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NET
 
Css3
Css3Css3
Css3
 
Vue.js - zastosowanie i budowa komponentów
Vue.js - zastosowanie i budowa komponentówVue.js - zastosowanie i budowa komponentów
Vue.js - zastosowanie i budowa komponentów
 
Html5 & CSS overview
Html5 & CSS overviewHtml5 & CSS overview
Html5 & CSS overview
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Styling recipes for Angular components
Styling recipes for Angular componentsStyling recipes for Angular components
Styling recipes for Angular components
 
CSS basic cheat sheet
CSS basic cheat sheetCSS basic cheat sheet
CSS basic cheat sheet
 
CSS- Smacss Design Rule
CSS- Smacss Design RuleCSS- Smacss Design Rule
CSS- Smacss Design Rule
 
Soa lab 3
Soa lab 3Soa lab 3
Soa lab 3
 
CSS Psuedo and beyond
CSS Psuedo and beyondCSS Psuedo and beyond
CSS Psuedo and beyond
 

Mehr von Михаил Петров (10)

JS Event Model
JS Event ModelJS Event Model
JS Event Model
 
DOM API Java Script
DOM API Java ScriptDOM API Java Script
DOM API Java Script
 
Object - Oriented Java Script
Object - Oriented Java ScriptObject - Oriented Java Script
Object - Oriented Java Script
 
strings and objects in JavaScript
strings and  objects in JavaScriptstrings and  objects in JavaScript
strings and objects in JavaScript
 
Arrays and Functions in JavaScript
Arrays and Functions in JavaScriptArrays and Functions in JavaScript
Arrays and Functions in JavaScript
 
JavaScript intro
JavaScript introJavaScript intro
JavaScript intro
 
Emmet(zen coding)
Emmet(zen coding)Emmet(zen coding)
Emmet(zen coding)
 
Html 5 Semantics overview
Html 5 Semantics overviewHtml 5 Semantics overview
Html 5 Semantics overview
 
Less & Sass
Less & SassLess & Sass
Less & Sass
 
Науката през погледа на младите
Науката през погледа на младитеНауката през погледа на младите
Науката през погледа на младите
 

Pseudo CSS Selectors