Custom Fields HTML or nth-child?

I am trying to utilize custom forms to fill in some security questions. There are random two questions pulled from a list of six possible options.

The forms have id’s: id=answer and id=answer2

 <ul>
  <li><span id=question1>What highschool did you attend?</span></li>
  <li><input type="text" id="answer" name="answer"></li>
  <li><span id=question2>What was your first pets name?</span></li>
  <li><input type="text" id="answer2" name="answer2"></li>
</ul> 

Is there a way to reference the custom fields to more than the ID or name in this example?

html="<li><span id=question1>What highschool did you attend?</span></li>
  <li><input type="text" id="answer" name="answer"></li>"

Or maybe indicate nth-child of something the inputs parent?