Hi eveeryoone,
Is it possible that span can have more the one id ?
i am tring like this

<span id="user Maxi">Maxi</span>
<span id="user John">John</span>
<span id="user Henry">Henry</span>
<span id="user Max">Max</span>
<span id="user Simon">Simon</span>

#user{
text-align:center;
display:inline-block;
width:50px;
height:20px;
background-color:#9B59B6;
margin:5px;
border:4px solid #3498DB;
color:#F1C40F;
cursor:pointer;
}

but it isnt working, why doesnt working css on this.

Recommended Answers

All 3 Replies

An id is meant to be a unique identifier. You can't have two unique identifiers on the same span, or same anything.
You can use multiple classes however - .user, .Maxi, .John, etc. But you don't give any styles for your Maxi, John, Henry etc styles. So without them, there will be no visible change.

It's just possible that the browser is trying to apply the styles for the last id you use, and in each case there are no styles for that id.

Ids can't be used like this, use classes insted , id must be one word and must be unique.

<span class="user" id="Maxi">Maxi</span>
<span class="user" id="John">John</span>
<span class="user" id="Henry">Henry</span>
<span class="user" id="Max">Max</span>
<span class="user" id="Simon">Simon</span>

.user{
text-align:center;
display:inline-block;
width:50px;
height:20px;
background-color:#9B59B6;
margin:5px;
border:4px solid #3498DB;
color:#F1C40F;
cursor:pointer;
}

you can use class for more than one entities. or you can use ajax for replacing the multiple ID

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.