[attribute~=value], attribute contains word - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:attribute contains word

Description

The [attribute~=value] selector selects elements whose attribute value contains the specified word.

Example

Select elements with a title attribute containing the word "test":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
[title~=test] {<!--from w ww  .  j a va 2s  . c  o  m-->
    border: 5px solid red;
}
</style>
</head>
<body>

<img src="https://www.java2s.com/style/demo/Opera.png" title="test case" width="150" height="113">
<img src="https://www.java2s.com/style/demo/Firefox.png" title="tests" width="224" height="162">
<img src="https://www.java2s.com/style/demo/Opera.png" title="this is a test" width="160" height="120">

</body>
</html>

Related Tutorials