Style HTML element based on its title using CSS

前端 未结 5 1748
慢半拍i
慢半拍i 2021-01-08 01:33

Is it possible to apply a style to an HTML element using only its title as a unique identifier? For example:


      
5条回答
  •  天命终不由人
    2021-01-08 02:10

    It sure is, using what's called attribute selectors; these are part of CSS2. In your particular case, you'd use:

    div.my_class a[title="MyTitle"] { color: red; }
    

    You can read more about attribute selectors here: http://www.w3.org/TR/CSS2/selector.html#attribute-selectors

提交回复
热议问题