-1

Example HTML:

<div itemid="MenuContainer" id="MenuContainer" class="MenuContainer">

Example CSS:

#MenuContainer {

   /* Styles */

}

How can I use CSS to target ItemID instead of the regular ID?

  • 4
    Why do you need to, and why are you making up attributes instead of using HTML5 custom data attributes? – j08691 Jan 20 '15 at 22:07
  • 2
    possible duplicate of [Select elements by data attribute in CSS](http://stackoverflow.com/questions/5324415/select-elements-by-data-attribute-in-css) – knitevision Jan 20 '15 at 22:11
  • knitevision = multiple accounts. check serial down voting on her rep. just ignore it. there are a lot of people like that on here. – Adam Joseph Looze Jan 20 '15 at 22:23

2 Answers2

4

Instead of #MenuContainer, use this.

[itemid="MenuContainer"] { /*CSS STYLES*/ }

This will use data attribute (itemid) and the value (MenuContainer) from the HTML tag.

see this http://jsfiddle.net/442hdc0p/

  • 1
    Yes I agree. How did you get two down votes? You answered with exactly what I needed. Thank you. When it lets me you get the green check. – Dustin Angeletti Jan 20 '15 at 22:20
  • Thank you Dustin, I believe it was knitevision. I checked her reputation and she has lost reputation on serial downvoting in the past. Guessing multiple accounts. She wasnt happy that aparently this question is similar to others. – Adam Joseph Looze Jan 20 '15 at 22:22
-1

You should not even try to do that. Instead, use unique class for this element. In your example you could add class="MenuContainer extraClass" and then in CSS use .extraClass { color: #FFF; } or whatever to define, what you need.

mrserge
  • 199
  • 9