Classes in CSS and HTML. How exactly do you use them in the CSS document?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hrstissiaopai
    New Member
    • Mar 2013
    • 27

    Classes in CSS and HTML. How exactly do you use them in the CSS document?

    Ummm.... I forgot! How do you define a define a tag which you have given a specific class in HTML in the CSS document? So say your HTML looks something like this:
    <p class="default" >Somerandomtext </p>
    So in this case how exactly do you formulate the CSS. Is it like this?
    p.default {color:red;}
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Yes, you can do that.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      p.default would select only <p> tags with that class. If you want to apply it to all elements that have class default then you would define the class as just

      Code:
      .default {
           color:red;
      }

      Comment

      • hrstissiaopai
        New Member
        • Mar 2013
        • 27

        #4
        Thanks so much for the quick response! I was looking for a community where people share questions and knowledge, and I finally found it. I am 12 and started learning HTML and CSS when I was nine, now I am studying JavaScript and Python.

        Comment

        • CygnetInfo
          New Member
          • Mar 2013
          • 27

          #5
          This is really great information which you have share. As HTML and CSS great platform to work on.

          Comment

          Working...