Can I use space to separate two id's?
<div class="g2 ">
<input type="text" id="noPosting number_only" disabled="true" name="post_every" value="" class="txt_r integer-365"/>
</div>
Can I use space to separate two id's?
<div class="g2 ">
<input type="text" id="noPosting number_only" disabled="true" name="post_every" value="" class="txt_r integer-365"/>
</div>
Putting a space in the ID value doesn't automatically make them two different IDs for the element. They can still be selected in CSS through #noPosting\ number_only
(notice the \
which escapes the blank space). They can also be selected in Javascript through something like document.getElementById('noPosting number_only')
.
#noPosting\ number_only {
background-color: yellow;
}
<div class="g2 ">
<div id="noPosting number_only">test</div>
</div>
If you need to have separate selectors, it is better to use a class selector instead. Alternatively, you could use the attribute selector to select such an element through the two parts of the value. See the example below:
[id*=noPosting] {
color: red;
}
[id*=number_only] {
background-color: yellow;
}
<div class="g2 ">
<div id="noPosting number_only">test</div>
</div>
You can read more about this here: What are valid values for the id attribute in HTML?
No, only one unique ID will work in HTML per element. But you can use more than one class in a single element in HTML, separated by space.