CSS Portal

CSS Selector List (,) Selector

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The Selector List (,) selector is a powerful CSS tool that allows multiple, distinct selectors to share a single set of style rules. By separating individual selectors with a comma, you can apply the same styles to different elements simultaneously, which helps reduce code repetition and keeps stylesheets cleaner and more maintainable. This is particularly useful when you want several unrelated elements to share common styling without writing separate rules for each.

Using a Selector List (,) is conceptually similar to combining multiple selectors, such as a type selector or a class selector, but instead of creating a hierarchy or relationship, each selector in the list is treated independently. The styles defined in the rule set are applied to all elements that match any of the selectors in the list. For example, you could target all paragraphs and all headings in a section and give them the same text color or font styling.

One practical advantage of Selector List (,) is its efficiency when managing theme changes or responsive design. Instead of duplicating identical declarations across multiple selectors, you can list all relevant selectors together. This becomes even more useful when combined with color, margin, or font-size properties, allowing for uniform styling across different types of content. For example, you might write a rule that targets both h1 and h2 elements, giving them the same font color, which ensures visual consistency across headings.

In practice, a Selector List (,) might look like this: multiple p and li elements could be targeted together so that both have the same spacing and text style. This approach streamlines CSS maintenance, reduces redundancy, and provides clear visibility of shared styling rules, making it easier for developers to manage complex layouts.

Syntax

element, element { css declarations; }

Example

<body>

<h1>Welcome to My Page</h1>
<h2>This is a Subtitle</h2>
<p>This is a regular paragraph of text.</p>

<span>This span will not be affected.</span>

</body>
/* The comma tells the browser to apply these styles to 
ALL h1, h2, and p elements */

h1, h2, p {
color: #2c3e50;
font-family: Arial, sans-serif;
border: 2px solid #3498db;
padding: 10px;
}

Browser Support

The following information will show you the current browser support for the CSS Selector List (,) selector. Hover over a browser icon to see the version that first introduced support for this selector.

This CSS selector list (,) selector is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 2nd January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!