The element selector$("element") (since jQuery 1.0) selects every node with that HTML tag name — the same idea as a CSS type selector. Official docs note jQuery uses native getElementsByTagName() for this expression.
Remember
$("div") // every <div>
$("p") // every <p>
$("span") // every <span>
$("div.card") // div + class
$("#box div") // divs under #box only
// Native twin: document.getElementsByTagName("div")
Write the tag name in lowercase, then narrow with class, id, or a parent when needed.
Pass the tag name: $("div"), $("li"), $("input").
Combine with a class or id when you need fewer matches: $("div.note").
Scope under a container on large pages: $("#panel p").
Use commas for several tags at once: $("h1, h2, h3").
Prefer lowercase tag names for consistency across HTML/XML contexts.
Piece
Required?
Role
Tag name
Yes
Matches element.tagName (e.g. div)
Class / id / ancestor
Optional
Narrows which tags are returned
Native path
—
getElementsByTagName() for bare tags
Return value
—
jQuery collection of matching elements
Pseudocode
Pseudocode
matches = getElementsByTagName(tagName) // native when bare
// or, conceptually:
matches = []
for each element in document (or context):
if element.tagName equals tagName:
matches.add(element)
return jQuery(matches)
Reference
Cheat Sheet
Keep these facts handy while selecting by tag name.
Topic
Detail
Syntax
$("tagName")
Since
jQuery 1.0 · CSS type selector
Native API
getElementsByTagName()
Case habit
Use lowercase tag names
+ class
$("div.card")
Scoped
$("#box span")
Multiple tags
$("div, p, span")
Empty set
No such tags → length 0
Try it
Live Preview
Run $("div"), $("span"), or both against the official-style sample boxes.
Sample markup
DIV1
DIV2
SPAN
Same idea as the official jQuery demo — tag name only, no class required.
Result
$("div").length
→ 2
matched → DIV1, DIV2
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Official $("div")
Select every div — spans and other tags are skipped.
One line:$("element") selects by tag name — fast and foundational, best when scoped or combined.
Frequently Asked Questions
The element selector matches every DOM node with a given HTML tag name. $("div") selects all div elements; $("p") selects all paragraphs. Available since jQuery 1.0 — the same idea as CSS type selectors.
Conceptually yes. Official jQuery docs state that getElementsByTagName() is used for a bare element selector. jQuery wraps the result so you can chain .css(), .on(), and other methods.
In HTML, tag matching is case-insensitive in the DOM, but convention is lowercase: $("div"), $("span"), $("input"). Lowercase avoids surprises in XML/XHTML documents.
Element selects by tag type. Class (.card) and ID (#header) narrow by attributes. Combine them: $("div.card") means div elements that also have class card.
Often no. Prefer scoping: $("#main div") or $("div.card"). A bare $("div") touches every div in the document and can over-style or over-bind.
Yes. It is the CSS type selector and has been in jQuery since 1.0. It works in native querySelectorAll as well when you need non-jQuery code.