Some developer
Some developer

Reputation: 43

How to call an HTML object with the 'name' tag?

Now this might be a dumb question and if so I sincerely apologise for wasting your time.

I was wondering how one was to call an HTML object with the 'name' tag. Here an example to explain what I mean:

HTML: <p id="one"></p>
CSS: #one{}

HTML: <p class="two"></p>
CSS: .two{}

HTML: <p name="three"></p>
CSS: ?

I need this because I'm working with commercial JavaScript UI components and they have a naming system based on name.

Thank you for taking the time to answer.

Upvotes: 0

Views: 1237

Answers (3)

Karuppiah RK
Karuppiah RK

Reputation: 3964

Use CSS attribute selector. p[name] css will affect all your <p></p> element with name attribute.

p[name] {
  background: green
}

p[name="three"] {
  background: red
}
<p name="two">text</p>

<p name="three">text</p>

Upvotes: 1

kk kk
kk kk

Reputation: 309

p[name="three"] { color:red }

you can select css by attribute tag

Upvotes: 1

Kamil Kiełczewski
Kamil Kiełczewski

Reputation: 92735

Try

[name='three'] {
  color: red
}
<p name="three">x</p>

Upvotes: 1

Related Questions