The pseudo-class :only-of-type selects an element which is the only child of its parent of a particular type.

color: yellow;


background-color: orchid; The :checked property of pseudo-class selects those input elements which are either –radio buttoncheckboxoptionsOnce, this selects any of these type of input elements, it can apply a particular style to these selected elements.



background: tomato; div:empty { :default

:default will select all the default elements of the form.

border: 1px solid green; color: red;

background-color: #F7DED7;

} If we wanted to make the first paragraph in an article larger and bold, we could add a class to that paragraph and then add CSS to that class, as shown in the first example below: Example:p:first-child {

:not() border:2px solid tomato;

CSS pseudo elements, example of CSS link pseudo-classes - :link and :visited, example of CSS dynamic-pseudo-classes-hover-active-and-focus, Scala Programming Exercises, Practice, Solution.

background: orange; :read-write


div:nth-last-child(2n) {



In the code example the :link pseudo … If you wish to select all the elements which are the only child of a particular type under their parent, then you can use this :only-of-type selector. margin: 4px 0 0 0;

} :visited box-shadow: 0px 0px 2px 2px tomato; background-color: #C4F7A2;

border: 4px dotted blue;

input:checked {

:lang margin-left: 50%; Pseudo-classes can be combined with CSS classes: The :first-child pseudo-class matches a specified element that is the first child of another element. There's nothing that works as a toggle button.

Example of :any-link pseudo-class

This selects the Last child of a parent element and applied a style on it. background-color: orange;

padding: 0; :disabled The pseudo-class :nth-last-child() selects all the elements which is determined by their position within all the siblings under a parent when you start counting from the last child.

This selects the Last child of a parent element and applied a style on it.Syntax::last-child }

The selector :last-of-type selects only the first element of a particular type among its sibling elements.Here, p:last-of-type will select only the last paragraph from all the group of paragraphs which are siblings with respect to each other.Similarly, div:last-of-type selects only the last div from all the siblings div type.

p:first-child {

font-size:20px; :nth-last-of-type padding:10px 20px; background-color: lawngreen;

Run the Code In short, those elements are not defined with “required” attribute. }

background-color: #fff;

Prev First Name:


text-align: center; An Internal link within the same page followed by # and the anchor name to that particular element is the :target selector. padding: 2px 1px;

The “readonly” tags are non-editable fields.

input:invalid {


Run the Code

:optional selects ,