T.Todua
T.Todua

Reputation: 56381

Style div (with specific tag), without class or id

I have like this div, that has no ID or CLASS attributes:

<div data-placement="kolp">
blabla
</div>

How can I target that in my CSS ? Maybe some javascript help is needed?

Upvotes: 2

Views: 6180

Answers (2)

Benjamin Crouzier
Benjamin Crouzier

Reputation: 41895

You can try this:

.container > div {
 /* targets your div if it's a direct child of container */
}

.container div {
 /* targets any div that is inside container */
}

div[data-placement=kolp] {
  /* targets any div with the attribute data-placement=kolp */
}

fiddle here: http://jsfiddle.net/JUP87/

Upvotes: 4

David Thomas
David Thomas

Reputation: 253318

You could use attribute-selectors:

div[data-placement] {
    /* selects all div elements with the 'data-placement' attribute */
}

/* or */

div[data-placement="kolp"] {
    /* selects all div elements with the 'data-placement' attribute which is equal to 'kolp' */
}

JS Fiddle demo.

References:

Upvotes: 2

Related Questions