Grow your CSS skills. Land your dream job.

Does a CSS Solution Exist for Unlinked Elements?

  • # January 9, 2013 at 11:55 am

    [http://jsfiddle.net/6PvLj/1/](http://jsfiddle.net/6PvLj/1/ “http://jsfiddle.net/6PvLj/1/”)

    Above I setup a JS Fiddle to demonstrate my current code.

    The gray boxes represent .classlinks, the black boxes #link_wrap a.

    Each item has a .classlinks wrapped around it. As you will notice, each item except one (2) is unlinked.

    How would I apply the gray background to the **unlinked element only** wikthout using nth-child? This is being used in WordPress for pagination, so the links are generated by WordPress, so the unlinked element is not static.

    # January 9, 2013 at 12:39 pm

    Use the span.

    You’ll have to make sure the colours match though, by explicitly setting one. In the fiddle below I used blue.

    http://jsfiddle.net/veaJW/

    # January 9, 2013 at 12:54 pm

    That didn’t do it. I was looking to apply the grey background to the unlinked element (2) only. This simply made everything one color.

    # January 9, 2013 at 1:04 pm

    Why not just give your middle span a different class and then target it with the CSS you want?

    Also your HTML is dodgy, you haven’t closed some of the spans.

    # January 9, 2013 at 1:15 pm

    Fixed. Because this is for WP_LINK_PAGES and adding a different class to the middle span would require a custom function. As i said, the links are generated in WP.

    # January 9, 2013 at 7:41 pm

    I came up with this

    http://jsfiddle.net/YBtAY/

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

You must be logged in to reply to this topic.

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