Grow your CSS skills. Land your dream job.

Selecting a classless paragraph

  • # January 26, 2013 at 11:16 pm

    Is there a way i can target a class-less or id-less tag? specifically a paragraph tag?

    # January 26, 2013 at 11:23 pm

    Yes you should be able to. You can target a paragraph within a certain div or other element, you’ll just have to get specific in your css. Let’s say you have a div class of “text” and you want to style that paragraph text different. In your css, you can call up:

    .text p {your styles}

    Of course this will work with other elements such as section, articles, etc. Hope that helps!

    # January 26, 2013 at 11:23 pm

    yes, but you’d have to give an example b/c the solution will definitely vary based on context.

    # January 26, 2013 at 11:37 pm

    oh god that was stupid… -_- and i got it :P

    # January 27, 2013 at 12:21 am

    @attilahajzer, it is better not to over specify class such as

    .text p {your styles}

    but use instead generic class like:

    .text-something {your styles}

    HTML

    My text

    That way you can reuse that class with other elements if necessary

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".