পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Wednesday, February 15, 2017

CSS - Pseudo Elements

CSS pseudo-elements are used to add special effects to some selectors. You do not need to use JavaScript or any other script to use those effects. A simple syntax of pseudo-element is as follows −
selector:pseudo-element {property: value}
CSS classes can also be used with pseudo-elements −
selector.class:pseudo-element {property: value}
The most commonly used pseudo-elements are as follows −
Value Description
:first-line Use this element to add special styles to the first line of the text in a selector.
:first-letter Use this element to add special style to the first letter of the text in a selector.
:before Use this element to insert some content before an element.
:after Use this element to insert some content after an element.

The :first-line pseudo-element

The following example demonstrates how to use the :first-line element to add special effects to the first line of elements in the document.
<html>
   <head>
      <style type="text/css">
         p:first-line { text-decoration: underline; }
         p.noline:first-line { text-decoration: none; }
      </style>
   </head>
   <body>
      <p class="noline"> This line would not have any underline because this belongs to  nline class.</p>
      
      <p>The first line of this paragraph will be underlined as defined in the CSS rule above. Rest of the lines in this paragraph will remain normal. This example shows how to use :first-line pseduo element to give effect to the first line of any HTML element.</p>
   </body>
</html>
It will produce the following link −

The :first-letter pseudo-element

The following example demonstrates how to use the :first-letter element to add special effects to the first letter of elements in the document.
<html>
   <head>
      <style type="text/css">
         p:first-letter { font-size: 5em; }
         p.normal:first-letter { font-size: 10px; }
      </style>
   </head>
   <body>
      <p class="normal"> First character of this paragraph will be normal and will have font size 10 px;</p>
      
      <p>The first character of this paragraph will be 5em big  as  defined in the CSS rule above. Rest of the characters in this paragraph will remain normal. This example shows how to use :first-letter pseduo element to give effect to the first characters  of any HTML element.</p>
   </body>
</html>
It will produce the following black link −

The :before pseudo-element

The following example demonstrates how to use the :before element to add some content before any element.
<html>
   <head>
      <style type="text/css">
         p:before
         {
            content: url(/images/bullet.gif)
         }
      </style>
   </head>
   <body>
      <p> This line will be preceded by a bullet.</p>
      <p> This line will be preceded by a bullet.</p>
      <p> This line will be preceded by a bullet.</p>
   </body>
</html>
It will produce the following black link −

The :after pseudo-element

The following example demonstrates how to use the :after element to add some content after any element.
<html>
   <head>
      <style type="text/css">
         p:after
         {
            content: url(/images/bullet.gif)
         }
      </style>
   </head>
   <body>
      <p> This line will be succeeded by a bullet.</p>
      <p> This line will be succeeded by a bullet.</p>
      <p> This line will be succeeded by a bullet.</p>
   </body>
</html>
It will produce the following black link −

No comments:

Post a Comment