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 8378195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:52:25+00:00 2026-06-09T15:52:25+00:00

While making a quick review on jQuery selectors, I came across this page in

  • 0

While making a quick review on jQuery selectors, I came across this page in w3schools.

In the Some More Examples table, the second row, it says:

$("p#intro:first")  | Selects the first <p> element with id="intro"

It says: the first element with id=”intro”. But AFAIK there can be only one element with a certain id in a valid HTML document.

The question is: is it ever allowed to have two (or more) elements with the same id in a valid HTML document, or this is a mistake in the tutorial? or even in jQuery?!

Is there something I’m missing?

  • 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-09T15:52:26+00:00Added an answer on June 9, 2026 at 3:52 pm

    Is it ever allowed to have two (or more) elements with the same id in a valid HTML document,

    No

    or this is a mistake in the tutorial?

    Sort of.

    Since you are allowed only one element with a given id, explicitly requesting the first one is redundant … in good documents.

    There might be some browsers which will error recover in such a way so as to provide you with multiple results (especially if jQuery passes things on to querySelectorAll rather than getElementById) when you have multiple elements with the same id (in an invalid document) and this might filter out the subsequent ones … but this isn’t something you should be doing in your own documents. It might be justifiable if you are writing JS to run over third party code in a known subset of browsers which you know error recover in that way.

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

Sidebar

Related Questions

While making my way through the wonderful world of IndexedDB, I came across code
Making a quick JQuery demo where clicking a table element changes it from black
While making my program i have come across this requirement that i have to
While making some final tests of a class-library that I'm writing for Windows Mobile
I just ran into this issue while making a GET request to a node.js
I'm starting with Ruby, and while making some test samples, I've stumbled against an
I want to center an image of unknown width/height on a page, while making
I'm working on a quick page intended for mobile browsers. While there is little
I am trying to build a fancy jquery dropdown menu ,while making the menu
While making some configurations to include JAVA_HOME in the environment, I created the file

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.