The attribute starts-with selector — written [name^="value"] — matches elements whose attribute value begins with your search string. Matching is case-sensitive. It is ideal for URL schemes, ID prefixes, and grouped field names — available since jQuery 1.0.
01
Syntax
[attr^="x"]
02
Prefix
Starts exactly
03
Case
Sensitive
04
Official
name^=news
05
vs $= *
Start not end
06
Since 1.0
CSS3 + jQuery
Fundamentals
Introduction
Many real-world naming patterns use prefixes: URL schemes (https://), server-generated IDs (ETI_1234), and grouped field names (billing_email, billing_city). The starts-with attribute selector lets you target those elements without listing every full name.
The caret-equals syntax [attribute^="value"] checks whether the attribute string begins with your prefix — nothing may precede it. jQuery has supported this selector since version 1.0, and browsers implement it natively through CSS3 attribute selectors.
Concept
Understanding the Starts-With Selector
Think of the attribute value as text on a line. The selector asks: “Do the first characters exactly equal my prefix?” If yes, the element matches.
name="newsletter" + [name^="news"] → matches (starts with news).
name="newsboy" + [name^="news"] → matches.
name="milkman" + [name^="news"] → no match (starts with milk).
If you need the substring anywhere in the value — not strictly at the start — use [attr*="value"] instead. Starts-with is stricter and usually clearer for schemes and prefix conventions.
attribute — the HTML attribute name (name, href, id, etc.).
value — prefix string the attribute value must begin with (case-sensitive).
Return value
A jQuery object containing every element whose attribute starts with the prefix.
Empty collection when no values match.
Official jQuery API example
jQuery
$( "input[name^='news']" ).val( "news here!" );
// Matches name="newsletter", name="newsboy"
// Does NOT match name="milkman"
Cheat Sheet
⚡ Quick Reference
name value
[name^="news"]
newsletter
Matches
newsboy
Matches
news
Matches (entire value is prefix)
milkman
No match
my_news
No match (prefix is my_)
Newsletter
No match (case differs)
Compare
📋 [attr^="x"] vs [attr$="x"] vs [attr*="x"]
Three substring operators — prefix, suffix, and anywhere — answer different questions.
Starts ^
[href^="https"]
Prefix at start
Ends $
[href$=".pdf"]
Suffix at end
Contains *
[href*="pdf"]
Anywhere in value
Exact =
[href="https"]
Full value only
Hands-On
Examples Gallery
Example 1 follows the official jQuery API demo. Examples 2–5 cover prefix rules, operator comparison, HTTPS links, and scoped form fields. Use the Try-it links to run each snippet.
📚 Official jQuery Demo
Set value on inputs whose name starts with news.
Example 1 — Official Demo: input[name^='news']
Official jQuery demo — fill inputs whose name attribute begins with the prefix news.
href: /assets/report.pdf
^=/assets: true
$=.pdf: true
*=report: true
Each operator checks a different part of the same string
How It Works
All three can match the same element for different reasons. Choose the operator that expresses your intent — prefix for paths and schemes, suffix for extensions, contains for loose substring search.
Example 4 — Mark External Links with a[href^='https://']
Style links whose URL begins with the secure https:// scheme.
jQuery
$( "a[href^='https://']" ).addClass( "secure-link" );
// Matches https://example.com and https://docs.site/page
// Does not match http:// or relative /about links
HTTPS links → class "secure-link"
HTTP and relative links → unchanged
How It Works
The prefix must be the first characters of href. Include the full scheme https:// so you do not accidentally match unrelated values that merely contain those letters elsewhere.
Example 5 — Scoped Fields #checkout input[name^='billing_']
Target billing fields inside one form by naming prefix convention.
jQuery
$( "#checkout input[name^='billing_']" ).addClass( "billing-field" );
// Matches billing_email, billing_city inside #checkout
// Ignores shipping_email and billing fields in other forms
billing_email, billing_city in #checkout → class "billing-field"
shipping_email and fields outside #checkout → not styled
How It Works
Teams often prefix related fields with billing_ or shipping_. The starts-with selector groups them without maintaining a long list of full names — jQuery docs note that shared CSS classes can be faster when you control the markup.
Field prefixes — input[name^='billing_'] for checkout forms.
Server IDs — [id^='ETI_'] for framework-generated element IDs.
Path roots — a[href^='/docs/'] for documentation sections.
Data attributes — [data-tab^='settings-'] for grouped tabs.
Image CDN paths — img[src^='https://cdn.'] for asset origins.
🧠 How jQuery Evaluates [attr^="value"]
1
Read attribute
Get the full string value from each candidate element.
DOM
2
Compare prefix
Check whether the value starts with the search string — case-sensitive.
Prefix
3
No leading chars
Nothing may precede the prefix — relative paths need ^="/docs" not ^="docs" alone on full URLs.
Exact start
4
^
Return collection
Matching elements become a jQuery object for chaining.
Important
📝 Notes
Available since jQuery 1.0 — standard CSS3 attribute selector.
Comparison is case-sensitive (per official jQuery docs).
Prefix must be the first characters — nothing may precede it.
Not the same as *= — substring anywhere vs strict prefix.
Official docs: useful for server-generated IDs, but CSS classes are often faster when you control markup.
Pair with element type and ID for performance: #checkout input[name^='billing_'].
Compatibility
Browser Support
The attribute starts-with selector is part of CSS3 and works in jQuery 1.0+. Evergreen browsers support it in native querySelectorAll. IE7+ supports attribute selectors with jQuery fallbacks where needed.
✓ CSS3 · jQuery 1.0+
jQuery [attribute^="value"]
Supported in all modern browsers. Native: document.querySelectorAll("a[href^='https://']"). Case-sensitive matching applies everywhere.
100%Standard CSS selector
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
[attr^="value"]Universal
Bottom line: Ideal for URL schemes and field prefixes. Use $= for suffixes and *= when the substring may appear in the middle.
Wrap Up
Conclusion
The attribute starts-with selector [name^="value"] matches when an attribute value begins with your prefix — case-sensitive and exact at the head. jQuery’s official demo, $("input[name^='news']").val("news here!"), demonstrates the pattern on form field names.
Use ^= for schemes and prefix conventions; use $= for suffixes and *= when position does not matter. Scope selectors to keep queries fast and readable on large pages.
Prefer shared CSS classes when you control the markup
❌ Don’t
Expect my_news to match [name^="news"]
Use ^= when *= is what you really need
Omit leading slashes on path prefixes (^="docs" vs full path)
Assume Newsletter matches ^="news"
Match very short prefixes like ^="n" without testing over-match risk
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about [attr^="value"]
Prefix match at the start of the value.
5
Core concepts
^01
^= syntax
Starts with
API
Aa02
Case
Sensitive
Rule
https03
Schemes
Common use
Pattern
≠ *04
Not *=
Strict head
Compare
news05
Official
name^=news
Demo
❓ Frequently Asked Questions
It selects elements whose named attribute value begins exactly with the given string. For example, [name^="news"] matches name="newsletter" and name="newsboy" because those values start with the prefix news.
Yes. jQuery and CSS attribute selectors use case-sensitive comparison for attribute values in HTML documents. name="Newsletter" does not match [name^="news"] because the casing differs at the start.
[attr^="https"] matches only when the value starts with https — https://example.com yes, http://example.com no. [attr*="https"] matches https anywhere in the value. [attr$=".pdf"] matches values that end with .pdf.
Yes. The attribute starts-with selector is standard CSS3 and has worked in jQuery since 1.0, with native querySelectorAll support in modern browsers.
Yes. a[href^="https://"] is a common pattern to target secure external links whose URL begins with the https:// scheme.
No. The prefix must be the first characters of the value. my_news starts with my_, not news. Use [name*="news"] if the substring may appear in the middle.
Did you know?
CSS attribute selectors form a family: = exact, ~= word, |= prefix-with-hyphen, ^= starts-with, $= ends-with, and *= contains. The caret operator ^= is the mirror of dollar $= — one checks the head, the other checks the tail.