Forums

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

Home Forums CSS use of ‘~’ in css

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #40883
    matthewb
    Member

    Hi guys,
    could anyone know about use of “~” in css. How does it works. Does it support all browsers including ie8?

    #114841
    JohnMotylJr
    Participant

    @matthewb : It’s used in specifying a certain word within the attribute,

    [title~=about] {
    background:#333;
    }

    That will target all elements with the word 'about' in the attribute of title.

    http://jsfiddle.net/john_motyl/JjrF4/

    What TheDoc said works best for what you want to know!

    #114842
    TheDoc
    Member

    It’s a sibling selector. All the info can be found here: https://css-tricks.com/child-and-sibling-selectors/

    #114843
    matthewb
    Member

    @TheDoc – Does it works as .nextAll() in jquery?

    #114845
    Kitty Giraudel
    Participant

    Yeah, it’s pretty much the same thing.

    .my-element ~ p

    This selector targets every p element after .my-element as long as they share the same direct parent.

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