Class Selector

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 40:- Class Selector

  1. A class selector in CSS is a type of selector that allows you to apply styles to elements with a specific class attribute. A class selector is denoted by a period (.) followed by the class name.

    For example, consider the following HTML code:

    cssCopy code

    <p class="highlight">This is a highlighted paragraph.</p> <p>This is a normal paragraph.</p>

    To style the first paragraph with a class of "highlight", you can use the following CSS code:

    cssCopy code

    .highlight {  background-color: yellow; }

    The CSS selector .highlight matches all elements with a class attribute of "highlight". In this case, the first paragraph will be styled with a yellow background. The second paragraph will not be affected because it does not have the "highlight" class.

    Multiple elements can have the same class, and a single element can have multiple classes. In this case, you can apply styles to all elements with a specific class, or a combination of classes. For example:

    pythonCopy code

    <p class="highlight special">This is a highlighted and special paragraph.</p> <p class="highlight">This is a highlighted paragraph.</p>

    You can use the following CSS code to apply styles to the first paragraph:

    cssCopy code

    .highlight.special {  background-color: green; }

    Here, the selector .highlight.special matches only the first paragraph with both "highlight" and "special" classes. The second paragraph will not be affected because it only has the "highlight" class.

5. Intro To CSS

2 Comments

@niteshguptav63
niteshguptav63 Nov 17, 2024 at 1:39 PM

I am not able to access videos from second class and further. I have already completed first class

@niteshguptav63
niteshguptav63 Nov 16, 2024 at 10:56 AM

When will I get my course?

@admin79
admin79 Nov 17, 2024 at 1:29 PM

Now, Your query was resolved.

Frequently Asked Questions About Sciaku Courses & Services

Quick answers to common questions about our courses, quizzes, and learning platform

Didn't find what you're looking for?

help_center Contact Support