Treehouse: Grow your CSS skills. Land your dream job.

Styling a menu that is given a dynamic ID

  • # March 7, 2013 at 5:31 pm

    Hello all,

    I am wondering if there is a way to hook to this css rule that is constantly changing:

    #accordion-menu-215-1-container .level1 dt .

    Every time a new instance of this menu is made the number increments by 1 to 216 etc.

    I researched the contains() selector on this site only to find that it is deprecated. Would I need to use LESS or even JS to approach this? I apologize if this a noob question and appreciate anyones help. Thanks,


    # March 7, 2013 at 5:47 pm

    CSS attribute selectors to the rescue:

    ul[id^=accordion-menu] {
    /* Your styles here. */


    # March 7, 2013 at 5:57 pm

    josh – you are the man. Thanks a lot .

    # March 7, 2013 at 6:15 pm

    Anytime. :)

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

You must be logged in to reply to this topic.