Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

html - <div> and <select> tags

Can I have a <DIV> within an HTML <SELECT> tag?

e.g.:

<select tabindex="2" name="agegrp" id="agegrp" >
    <div> 
        <option value="-1">No preference</option>
    </div>
</select>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the specification:

<!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->

i.e. There is an element called "SELECT", the start tag is required, the end tag is required. It's children can be OPTGROUP elements and/or OPTION elements and there must be at least one of them.

Since a DIV is not an OPTGROUP or an OPTION, the answer is no.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...