Web components: plainly explained.

Web components are native browser standards to build reusable custom HTML elements. Learn how they work, how they differ from frameworks and when to use them.

Webapp · Updated Nov 7, 2026

DEFINITION

Web components are a set of browser standards that let developers build reusable custom HTML elements with their own markup, style and behavior.

CATEGORY

Webapp

RELATED

dev, Front end

Summarize this page with AI

01

What are web components?

Web components are a set of native browser standards for creating reusable, self-contained HTML elements. A developer defines a new tag, such as <product-card>, with its own markup, styles and logic, then uses it on any page like a built-in element.

Because they are part of the platform, web components need no framework and work in every modern browser. They are a common way to share interface pieces between projects and between teams that use different technologies.

02

The three standards behind web components

  • Custom elements: define new HTML tags and their lifecycle.
  • Shadow DOM: encapsulates markup and CSS so styles do not leak in or out.
  • HTML templates: declare inert markup with <template> and <slot> that is cloned when needed.
03

How to create a custom element

class HelloCard extends HTMLElement {
connectedCallback() {
const root = this.attachShadow({ mode: 'open' });
root.innerHTML = `<p>Hello, ${this.getAttribute('name')}</p>`;
}
}
customElements.define('hello-card', HelloCard);

The element is then used in HTML with <hello-card name="Alex"></hello-card>. The browser runs the class code whenever the tag appears in the page.

04

Web components vs framework components

Criteria
RuntimeWeb componentsNative browser APIsFramework componentsFramework library
PortabilityWeb componentsWorks in any stackFramework componentsTied to one framework
Style isolationWeb componentsBuilt in with Shadow DOMFramework componentsDepends on the tooling
State and renderingWeb componentsManual or via a small helper libraryFramework componentsProvided by the framework
05

Best practices and pitfalls

  • Use them for shared, framework-independent interface pieces such as buttons, cards or widgets.
  • Expose customization through attributes, slots and CSS custom properties.
  • Keep meaningful content in the light DOM when it matters for search engines, since content in the shadow DOM may be harder to index.
  • Follow accessibility basics: roles, labels and keyboard support are not automatic.
  • Consider a light helper library such as Lit to reduce boilerplate.
06

Web components at BeBranded

Reusable components are the base of a maintainable product, whichever stack is chosen. When we build a web app, our team decides case by case between native web components and a framework, based on reuse needs, performance and the skills of the client team.

FAQ

Questions about Web components.

Another question?

Write to us
What are web components?
Web components are native browser standards (custom elements, Shadow DOM and HTML templates) for building reusable HTML elements with their own style and behavior.
Do web components need a framework?
No. They run on browser APIs alone. Small libraries such as Lit can simplify writing them, but they are optional.
What is the Shadow DOM?
The Shadow DOM is an isolated DOM tree attached to an element. Its markup and CSS are encapsulated, so they do not conflict with the rest of the page.
Are web components good for SEO?
They can be, if the important content stays in the regular DOM or is server-rendered. Content hidden in the shadow DOM may be harder for crawlers to use.
Can I use web components with React or Vue?
Yes. Custom elements are standard HTML tags, so most frameworks can render them, with some care for props and events.
Are web components supported in all browsers?
Yes, all current major browsers support custom elements, Shadow DOM and templates.

Related

Related terms, and where to go next.

How to select the right no-code tools
No-Code

How to select the right no-code tools

Learn how to select the right no-code tools for your needs. Essential criteria, common mistakes to avoid, and practical tips for successful digital projects.

Read the article
Memberstack: manage users on Webflow easily
No-Code

Memberstack: manage users on Webflow easily

Discover how Memberstack transforms Webflow sites with no-code membership features for seamless user management and monetization.

Read the article
Bubble vs. WeWeb: which no-code tool should you choose for your web application?
No-Code

Bubble vs. WeWeb: which no-code tool should you choose for your web application?

Bubble vs. WeWeb: which tool is best for your web app? Discover features, scalability, SEO performance, pricing and ease of use to choose the right platform.

Read the article

Let’s talk

Tell us what you want to build.

Thirty minutes with the people who will work on your project. You leave with a clear view of the scope, the timeline and the next steps.

What happens next

  1. 1A 30-minute callWe listen to your goals, your constraints and your context.
  2. 2A clear scopeWe map what is worth doing first, and what it takes.
  3. 3A costed proposalYou decide, with no commitment and no sales pitch.