Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to select previous element of the selected element

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #260249
    BhasSuresh
    Participant

    I would like to highlight “My Content 1” alone using the attribute value of Attrib. Am able to highlight “Attributes List” using the CSS-code mentioned in the style but I want to select it in reverse. Could someone please let me know how to to it.

    Here’s the HTML code link: https://codepen.io/BhasSuresh/pen/WZwaOY

    Content ~ Attrib {background-color:blue}

    The content of the body element is displayed in your browser.

    My Content 1
    Attributes List

    My Content 2
    Attributes List

    #260257
    Paulie_D
    Moderator

    You can’t do that with CSS.

    There is no previous sibling selector.

    Also, I’m sure the code you provided was just for demonstration purposes but you seem to be using custom HTML elements.

    Unless you know how to do this properly I’d recommend not using non-standard HTML elements. There are mroe than enough standard elements that could be used.

    #260258
    Paulie_D
    Moderator

    However, if you can amend the HTML structure and play with the CSS layout…you can fake it.

    https://codepen.io/Paulie-D/pen/bopZMN

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.