Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:21:41+00:00 2026-06-10T14:21:41+00:00

I have the following HTML: <ul class=’dropSelect’> <li data-value=one> <span>Menu1</span> </li> <li data-value=two> <span>Menu2</span>

  • 0

I have the following HTML:

<ul class='dropSelect'>
    <li data-value="one">
        <span>Menu1</span>
    </li>
    <li data-value="two">
        <span>Menu2</span>
    </li>
    <li data-value="three">
        <span>Menu3</span>
    </li>
</ul>

My question is: is it better practice to place the data-value attribute on the span next to the actual menu item text or is it just as good to place on the parent li element as I have done? This attribute will receive data from a web service and I’m using some js to grab the value of this attribute and placing it inside of another element on the page.

SOF warned me upon posting this question that it might be too subjective … and it might be … but my concern is to understand what, if any, impact my placement of this attribute may have on UI engineering, javascript DOM manipulation, accessibility, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:21:42+00:00Added an answer on June 10, 2026 at 2:21 pm

    Although html5 data attributes are subjective, and can be used anytime/anywhere, I’m assuming you are looking these elements up by them in your situation. In your situation I’d put them in the same place you did for a couple of reasons.

    • This is the top level (child), so it’s very easy to grab them all by the data attribute.
      $('li[data-value]')

    • At some point you might have much more inside each <li>, right now it might only be the <span> but by having the list-item hold the data-value you can easily get other DOM elements inside of it. If you had it inside of the span you’d have to go UP a level to the list-item, then .find() whatever element you want.

    If your span held data-value:

    $('[data-value="whatever"]').closest('li').find('.someOtherThing');

    Instead now you don’t have to do that pointless look-up for the parent <li>!

    $('[data-value="whatever"]').find('.someOtherThing');

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML. <div class=red>Div One</div> <div class=green>Div Two</div> <div class=blue>Div Three</div>
I have the following HTML: <ul> <li class=one><a href=#>one</a></li> <li class=two><a href=#>two</a></li> <li class=three><a
I have the following html code: <div class=tests> <input name=premise id=premise type=radio class=required value=0><span>0</span>
I have the following html : <div class=mainmenu> <ul class=blue> <li class=><a href=tst/ id=a1_up><span
Let's say we have the following html: <ul id=portfolio-list class=clearfix span-24> <li class=2012#foo bar
I have the following html structure: <div class=divClass> <a class=aClass href=#> <img src=xxxx.jpg <span
I have the following html code: <div class=result hide id=userNameTooShort><span class=error>Your username needs to
I have the following HTML (..) <tbody> <tr> <td class=name> Test1 </td> <td class=data>
I have the following HTML code: <div class=container> <span class=red></span> <span class=hot></span> </div> On
I have the following HTML dinamically generated: ... <tr> <td><input type=text class=q value=5 name=q[]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.