/    Sign up×
Community /Pin to ProfileBookmark

option tag requirements for datalist

Is closing option tag required for a datalist like it is for a select drop down element?

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@sibertNov 18.2021 — I have seen both closed and unclosed </option>

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist
Copy linkTweet thisAlerts:
@JMRKERauthorNov 18.2021 — I have tried it both ways (with and without closing /option tag)

Seems to work both ways for both a datalist entry as well as a regular select element.

Appears to validate both ways as well.

Any drawbacks if closing /option tag is NOT used with javascript code you might know of?

Would tag be missed if walking the DOM?

Just trying to find the most correct way to code this.
Copy linkTweet thisAlerts:
@daveyerwinNov 19.2021 — @JMRKER#1639581


https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
Copy linkTweet thisAlerts:
@JMRKERauthorNov 19.2021 — @DaveyErwin#1639637 Thank you. That is the most comprehensive list of optional tags I have ever seen.

While I'll probably continue to use the closing tags, it is nice to know that some are optional under certain conditions.
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...