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
  • #260249

    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:

    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


    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.


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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.