4

Is it possible to style an html element (div) by its data member f.e. data-name?

my div:

<div data-name="random_name">...</div> 

And is it possible to grab the element by data member that contains certain phrase?

f.e. i want to grab and style every element that its data member contains:

random* 
2
  • 1
    'div[data-name="random_name"] {color:red;} Commented Sep 23, 2016 at 7:41
  • Thank you and I'm sorry. Commented Sep 23, 2016 at 9:17

1 Answer 1

7

Use below

div[data-name="random_name"] {border:1px solid red;padding:10px;} 
<div data-name="random_name">Random name</div>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.