{"id":5675,"date":"2015-07-16T12:15:56","date_gmt":"2015-07-16T09:15:56","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=5675"},"modified":"2018-01-08T14:18:40","modified_gmt":"2018-01-08T12:18:40","slug":"css-pseudo-class-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/","title":{"rendered":"CSS Pseudo Class Example"},"content":{"rendered":"<p>In this example we are talking about CSS pseudo-classes concept.<\/p>\n<p>A CSS pseudo-class is a keyword added to selectors that specifies a special state of the element to be selected. For example <code>:hover<\/code> will apply a style when the user hovers over the element specified by the selector.<\/p>\n<p>A pseudo-class is used to define a special state of an element.<\/p>\n<p>Outside of IE, they have great browser support. In IE land, even IE8, support is pretty barren. However, the IE9 has full support of them.<\/p>\n<p>Below we will have a look at the general structure and then exmaples.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;nAkUl5IbAjqlXSla&#8217;]<\/p>\n<h2>1. Basic Document Setup<\/h2>\n<p>Go ahead and create a new html document and add the basic sytnax in it like so:<\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;title&gt;CSS Pseudo Class Example&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;!-- STYLE SECTION --&gt;\r\n\r\n&lt;style type=\"text\/css\"&gt;\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;!-- HTML SECTION --&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In the HTML section, we will be adding elements and in the style section refer to these elements and use pseudo-classes.<\/p>\n<h2>2. Syntax and What&#8217;s New in CSS3?<\/h2>\n<p>Before applying any of the pseudo classes, here you have the basic syntax to be applied.<\/p>\n<pre class=\"brush:css\">selector:pseudo-class {\r\n  property: value;\r\n} \r\n<\/pre>\n<p>In CSS3 apart from pseudo-classes that already existed like <code>:hover<\/code>, <code>:active<\/code>, <code>:checked<\/code>, <code>:default<\/code>, there are a ton of new pseudo classes. Below you can find most of the new pseudo classes and a short explanation for each of them:<\/p>\n<ul>\n<li><code>:nth-child(N)<\/code> &#8211; matches elements on the basis of their positions within a parent element\u2019s list of child elements<\/li>\n<li><code>:nth-last-child(N)<\/code> &#8211; matches elements on the basis of their positions within a parent element\u2019s list of child elements<\/li>\n<li><code>:nth-of-type(N)<\/code> &#8211; matches elements on the basis of their positions within a parent element\u2019s list of child elements<\/li>\n<li><code>:nth-last-of-type(N) - <\/code> matches elements on the basis of their positions within a parent element\u2019s list of child elements<\/li>\n<\/ul>\n<p>Understanding <code>:nth-child<\/code> pseudo-class expressions:<\/p>\n<ul>\n<li><code>:last-child<\/code> &#8211; matches an element that\u2019s the last child element of its parent element<\/li>\n<li><code>:first-of-type<\/code> &#8211; matches the first child element of the specified element type<\/li>\n<li><code>:last-of-type<\/code> &#8211; matches the last child element of the specified element type<\/li>\n<li><code>:only-child<\/code> &#8211; matches an element if it\u2019s the only child element of its parent<\/li>\n<li><code>:only-of-type<\/code> &#8211; matches an element that\u2019s the only child element of its type<\/li>\n<li><code>:root<\/code> &#8211; matches the element that\u2019s the root element of the document<\/li>\n<li><code>:empty<\/code> &#8211; matches elements that have no children<\/li>\n<li><code>:target<\/code> &#8211; matches an element that\u2019s the target of a fragment identifier in the document\u2019s URI<\/li>\n<li><code>:enabled<\/code> &#8211; matches user interface elements that are enabled<\/li>\n<li><code>:disabled<\/code> &#8211; matches user interface elements that are disabled<\/li>\n<li><code>:checked<\/code> &#8211; matches elements like checkboxes or radio buttons that are checked<\/li>\n<\/ul>\n<h2>3. Cases and Examples<\/h2>\n<h3>3.1 Link-related pseudo class selectors<\/h3>\n<p><code>:link<\/code> &#8211; use this class to add special style to an unvisited link. For example:<\/p>\n<pre class=\"brush:xml\">&lt;!-- HTML SECTION  --&gt;\r\n&lt;a class=\"link\" href=\"#\"&gt;Link Selector&lt;\/a&gt;\r\n<\/pre>\n<pre class=\"brush:css\">&lt;style type=\"text\/css\"&gt;\r\n  .link:link{\r\n    color: green;\r\n    font-size: 20px;\r\n    font-weight: bold;\r\n  }\r\n&lt;\/style&gt;\r\n<\/pre>\n<figure id=\"attachment_5694\" aria-describedby=\"caption-attachment-5694\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-5694\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-1.jpg\" alt=\":link Pseudo Class Example\" width=\"820\" height=\"82\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-1.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-1-300x30.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-5694\" class=\"wp-caption-text\">:link Pseudo Class Example<\/figcaption><\/figure>\n<p><code>:visited<\/code> &#8211; selects links that have already been visited by the current browser. Using the example above:<\/p>\n<pre class=\"brush:css\">&lt;style type=\"text\/css\"&gt;\r\n  .link:visited {\r\n    color: red;\r\n  }\r\n&lt;\/style&gt;\r\n<\/pre>\n<figure id=\"attachment_5697\" aria-describedby=\"caption-attachment-5697\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-5697\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-2.jpg\" alt=\":visited Pseudo Class Example\" width=\"820\" height=\"82\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-2.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-2-300x30.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-5697\" class=\"wp-caption-text\">:visited Pseudo Class Example<\/figcaption><\/figure>\n<p><code>:hover<\/code> &#8211; when the mouse cursor rolls over a link, that link is in it&#8217;s hover state and this will select it.<\/p>\n<p><code>:active<\/code> &#8211; selects the link while it is being activated (being clicked on or otherwise activated).<\/p>\n<pre class=\"brush:css\">&lt;style type=\"text\/css\"&gt;\r\n  .link:hover{\r\n    color: #478fc1;\r\n  }\r\n  .link:active{\r\n    color: black;\r\n  }\r\n&lt;\/style&gt;\r\n<\/pre>\n<figure id=\"attachment_5699\" aria-describedby=\"caption-attachment-5699\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-5699\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-3.jpg\" alt=\":hover and :active Pseudo Classes Example\" width=\"820\" height=\"82\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-3.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-3-300x30.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-5699\" class=\"wp-caption-text\">:hover and :active Pseudo Classes Example<\/figcaption><\/figure>\n<h3>3.2 Input &amp; link related pseudo class selectors<\/h3>\n<p><code>:focus<\/code> &#8211; selects links that are the current focus of the keyboard. This is not limited to links, but can be used (and really should be used) on inputs and textareas as well. Here is the HTML with an added form to show the example.<\/p>\n<pre class=\"brush:xml\">&lt;form&gt;  &lt;!-- added a form here --&gt;\r\n  &lt;label&gt;Name&lt;\/label&gt;\r\n  &lt;input type=\"text\" placeholder=\"Name\"&gt;\r\n  &lt;label&gt;E-Mail&lt;\/label&gt;\r\n  &lt;input type=\"text\" placeholder=\"E-Mail\"&gt;\r\n  &lt;label&gt;Address&lt;\/label&gt;\r\n  &lt;input type=\"text\" placeholder=\"Address\"&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<pre class=\"brush:css\">&lt;style type=\"text\/css\"&gt;\r\ninput:focus{\r\n  background-color: #ffffe5;\r\n}\r\n&lt;\/style&gt;\r\n<\/pre>\n<figure id=\"attachment_5702\" aria-describedby=\"caption-attachment-5702\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-5702\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-4.jpg\" alt=\":focus Pseudo Class Example\" width=\"820\" height=\"184\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-4.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-4-300x67.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-5702\" class=\"wp-caption-text\">:focus Pseudo Class Example<\/figcaption><\/figure>\n<p><code>:target<\/code> &#8211; the target pseudo class is used in conjunction with IDs, and match when the hash tag in the current URL matches that ID. So if you are at URL www.yoursite.com\/#home then the selector #home:target will match.<\/p>\n<p>That can be extremely powerful. For example, you can create a tabbed area where the tabs link to hash tags and then the panels &#8220;activate&#8221; by matching :target selectors and (for example) using z-index to move to the top.<\/p>\n<p><code>:enabled<\/code> &#8211; selects inputs that are in the default state of enabled and ready to be used.<\/p>\n<p><code>:disabled<\/code> &#8211; selects inputs that have the disabled attribute. A lot of browsers will make the input a faded out gray, you can control that with this selector.<\/p>\n<pre class=\"brush:xml\">&lt;form&gt;  &lt;!-- added a form here --&gt;\r\n  &lt;label&gt;Name&lt;\/label&gt;\r\n  &lt;input type=\"text\" placeholder=\"Name\"&gt;\r\n  &lt;label&gt;E-Mail&lt;\/label&gt;\r\n  &lt;input type=\"text\" placeholder=\"E-Mail\"&gt;\r\n  &lt;label&gt;Address&lt;\/label&gt;\r\n  &lt;input disabled type=\"text\" placeholder=\"Address\"&gt; &lt;!-- added disabled attribute --&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<pre class=\"brush:css\">&lt;style type=\"text\/css\"&gt;\r\ninput:disabled{\r\n  background-color: #ccc;\r\n}\r\n&lt;\/style&gt;\r\n<\/pre>\n<figure id=\"attachment_5706\" aria-describedby=\"caption-attachment-5706\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-5706\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-5.jpg\" alt=\":disabled Pseudo Selector Example\" width=\"820\" height=\"184\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-5.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-5-300x67.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-5706\" class=\"wp-caption-text\">:disabled Pseudo Selector Example<\/figcaption><\/figure>\n<h3>3.3 Position\/Number-based pseudo class selectors<\/h3>\n<p><code>:first-child<\/code> &#8211; Selects the first element within a parent.<\/p>\n<p><code>:last-child<\/code> &#8211; Selects the last element within a parent.<\/p>\n<pre class=\"brush:xml\">&lt;div&gt;\r\n  &lt;div&gt;&lt;h3&gt;This is a heading.&lt;\/h3&gt;&lt;\/div&gt;\r\n  &lt;div&gt;&lt;p&gt;This is just a text.&lt;\/p&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<pre class=\"brush:css\">&lt;style type=\"text\/css\"&gt;\r\ndiv:first-child{\r\n  font-size: 30px;\r\n  color: green;\r\n}\r\ndiv:last-child{\r\n  font-size: 20px;\r\n  color: red;\r\n}\r\n&lt;\/style&gt;\r\n<\/pre>\n<figure id=\"attachment_5710\" aria-describedby=\"caption-attachment-5710\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-5710\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-6.jpg\" alt=\":first-child and last-child Pseudo Class Example\" width=\"820\" height=\"184\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-6.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-6-300x67.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-5710\" class=\"wp-caption-text\">:first-child and last-child Pseudo Class Example<\/figcaption><\/figure>\n<p><code>:nth-child(N)<\/code> &#8211; Selects elements based on a simple provided algebraic expression (e.g. &#8220;2n&#8221; or &#8220;4n-1&#8221;). Has the ability to do things like select even\/odd elements, &#8220;every third&#8221;, &#8220;the first five&#8221;, and things like that. Covered in more detail here with a tester tool.<\/p>\n<pre class=\"brush:xml\">&lt;div&gt;\r\n  &lt;div&gt;&lt;h3&gt;This is a heading.&lt;\/h3&gt;&lt;\/div&gt;\r\n  &lt;div&gt;&lt;p&gt;This is just a text.&lt;\/p&gt;&lt;\/div&gt;\r\n  &lt;div&gt;&lt;p&gt;This is just a text.&lt;\/p&gt;&lt;\/div&gt;\r\n  &lt;div&gt;&lt;p&gt;This is just a text.&lt;\/p&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<pre class=\"brush:css\">&lt;style type=\"text\/css\"&gt;\r\ndiv:nth-child(3){\r\n  background-color: yellow;\r\n}\r\n&lt;\/style&gt;\r\n<\/pre>\n<figure id=\"attachment_5712\" aria-describedby=\"caption-attachment-5712\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-7.jpg\"><img decoding=\"async\" class=\"size-full wp-image-5712\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-7.jpg\" alt=\":nth-child Pseudo Class Exmaple\" width=\"820\" height=\"184\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-7.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/pseudo-classes-7-300x67.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-5712\" class=\"wp-caption-text\">:nth-child Pseudo Class Exmaple<\/figcaption><\/figure>\n<p><code>:first-of-type<\/code> &#8211; Selects the first element of this type within any parent. So if you have two divs, each had within it a paragraph, image, paragraph, image. Then div img:first-of-type would select the first image inside the first div and the first image inside the second div.<\/p>\n<p><code>:last-of-type<\/code> &#8211; Same as above, only would select the last image inside the first div and the last image inside the 2nd div.<\/p>\n<h2>4. Conclusion<\/h2>\n<p>Pseudo-classes, together with pseudo-elements, let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator (:visited, for example), the status of its content (like :checked on some form elements), or the position of the mouse (like :hover which lets you know if the mouse is over an element or not). Feel free to play around with these pseudo classes to get used to them.<\/p>\n<h2>5. Download<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/06\/CSS-Pseudo-Class.zip\"><strong>CSS Pseudo Class<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are talking about CSS pseudo-classes concept. A CSS pseudo-class is a keyword added to selectors that specifies a special state of the element to be selected. For example :hover will apply a style when the user hovers over the element specified by the selector. A pseudo-class is used to define a &hellip;<\/p>\n","protected":false},"author":75,"featured_media":917,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-5675","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CSS Pseudo Class Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example we are talking about CSS pseudo-classes concept. A CSS pseudo-class is a keyword added to selectors that specifies a special state of the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Pseudo Class Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example we are talking about CSS pseudo-classes concept. A CSS pseudo-class is a keyword added to selectors that specifies a special state of the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/fabiocimo\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-16T09:15:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-08T12:18:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Fabio Cimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fabiocimo\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fabio Cimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/\"},\"author\":{\"name\":\"Fabio Cimo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\"},\"headline\":\"CSS Pseudo Class Example\",\"datePublished\":\"2015-07-16T09:15:56+00:00\",\"dateModified\":\"2018-01-08T12:18:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/\"},\"wordCount\":971,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"articleSection\":[\"CSS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/\",\"name\":\"CSS Pseudo Class Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"datePublished\":\"2015-07-16T09:15:56+00:00\",\"dateModified\":\"2018-01-08T12:18:40+00:00\",\"description\":\"In this example we are talking about CSS pseudo-classes concept. A CSS pseudo-class is a keyword added to selectors that specifies a special state of the\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/css\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSS Pseudo Class Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\",\"name\":\"Fabio Cimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"caption\":\"Fabio Cimo\"},\"description\":\"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.\",\"sameAs\":[\"https:\/\/www.facebook.com\/fabiocimo\",\"https:\/\/al.linkedin.com\/in\/fabiocimo\",\"https:\/\/x.com\/fabiocimo\",\"https:\/\/www.youtube.com\/fabiocimo1\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS Pseudo Class Example - Web Code Geeks - 2026","description":"In this example we are talking about CSS pseudo-classes concept. A CSS pseudo-class is a keyword added to selectors that specifies a special state of the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/","og_locale":"en_US","og_type":"article","og_title":"CSS Pseudo Class Example - Web Code Geeks - 2026","og_description":"In this example we are talking about CSS pseudo-classes concept. A CSS pseudo-class is a keyword added to selectors that specifies a special state of the","og_url":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/fabiocimo","article_published_time":"2015-07-16T09:15:56+00:00","article_modified_time":"2018-01-08T12:18:40+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","type":"image\/jpeg"}],"author":"Fabio Cimo","twitter_card":"summary_large_image","twitter_creator":"@fabiocimo","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Fabio Cimo","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/"},"author":{"name":"Fabio Cimo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22"},"headline":"CSS Pseudo Class Example","datePublished":"2015-07-16T09:15:56+00:00","dateModified":"2018-01-08T12:18:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/"},"wordCount":971,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","articleSection":["CSS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/","url":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/","name":"CSS Pseudo Class Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","datePublished":"2015-07-16T09:15:56+00:00","dateModified":"2018-01-08T12:18:40+00:00","description":"In this example we are talking about CSS pseudo-classes concept. A CSS pseudo-class is a keyword added to selectors that specifies a special state of the","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/css\/css-pseudo-class-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"CSS","item":"https:\/\/www.webcodegeeks.com\/category\/css\/"},{"@type":"ListItem","position":3,"name":"CSS Pseudo Class Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22","name":"Fabio Cimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","caption":"Fabio Cimo"},"description":"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.","sameAs":["https:\/\/www.facebook.com\/fabiocimo","https:\/\/al.linkedin.com\/in\/fabiocimo","https:\/\/x.com\/fabiocimo","https:\/\/www.youtube.com\/fabiocimo1"],"url":"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/5675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=5675"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/5675\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/917"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=5675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=5675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=5675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}