I wouldn't say it's bad practice, but it's really overkill in almost any kind of situation and it will make your HTML markup invalid according to the W3 Validator. What you could do instead is give your element a class and then refer to it in JavaScript by using getElementByClass
:
// Grabs the first element with said class
var foo = document.getElementsByClassName()[0];