Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CSS controls how HTML is presented: it sets colors, typography, spacing, and layout. A CSS rule uses a selector to choose elements, then declarations to style them. This tutorial explains the core syntax, selector types, practical examples, and how to think about the term “CSS3” today.

What CSS does—and what “CSS3” means

Cascading Style Sheets (CSS) describes how structured documents such as HTML are rendered. The W3C describes CSS as a language for describing the rendering of structured documents on screen, on paper, and in other contexts. See the W3C CSS overview.

“CSS3” is still a familiar name for modern CSS, but it does not identify one finished specification containing every current feature. CSS is developed as separate modules, and the W3C specifications index tracks their status. The latest stable snapshot named by the W3C overview at the time of writing is CSS Snapshot 2026.

A specification’s maturity and browser support are separate questions. The W3C’s CSS Snapshot 2025, a Note dated 25 February 2025, explains that snapshot inclusion reflects specification stability, not a promise of adoption by browsers. Check support for a specific feature before relying on it in production.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

CSS rule syntax

A stylesheet pairs a selector with a declaration block. The selector identifies the elements that match; each declaration sets a property to a value.

p {
  color: rebeccapurple;
  line-height: 1.5;
}
  • p is the selector; it matches paragraph elements.
  • color and line-height are properties.
  • rebeccapurple and 1.5 are their respective values.
  • Braces enclose the declarations, and semicolons separate them.

CSS can be placed in a stylesheet linked from HTML, in a <style> element, or in an element’s style attribute. A separate stylesheet is usually the clearest choice when styles are shared across a page or site.

Core selector types

Selectors can target elements by type, class, ID, attributes, state, or structural position. These established examples show the main patterns:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
/* Type: every paragraph */
p { color: #333; }

/* Class: elements with class="notice" */
.notice { padding: 1rem; }

/* ID: the element with id="main-content" */
#main-content { max-width: 70ch; }

/* Attribute: email inputs */
input[type="email"] { border-color: teal; }

/* Pseudo-class: links while hovered */
a:hover { text-decoration: underline; }

Type selectors

A type selector is the element name, such as p, h1, or button. It applies to every matching element, so it is useful for broad defaults.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Class selectors

A class selector begins with a period. In HTML, assign the class in the class attribute, then use the same name in CSS:

<p class="notice">Your changes were saved.</p>

.notice can be reused on multiple elements, including elements of different types. This makes classes a practical way to apply a shared visual role.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

ID selectors

An ID selector begins with # and matches an element with the corresponding id value:

<main id="main-content">...</main>

Use an ID when you need to target an element by its ID. HTML authors generally intend an ID to identify one element in a document; do not treat that convention as a styling technique for reusable components.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Attribute selectors

Attribute selectors match elements based on an attribute or its value. For example, input[type="email"] selects email inputs without applying the rule to every input.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Pseudo-classes

A pseudo-class, written with a colon, selects an element in a particular state or position. :hover matches an element while the pointer hovers over it. Other examples include state and structural selectors; check current support for less familiar or newer selectors in the MDN CSS selectors guide.

Combinators: select by document relationships

Combinators join selectors to describe relationships between elements in the document tree:

Combinator Relationship Example What it matches
Space Descendant article p Paragraphs anywhere inside an article
> Direct child nav > a Links that are direct children of a navigation element
+ Adjacent sibling h2 + p A paragraph immediately following an h2 with the same parent
~ Subsequent sibling h2 ~ p Paragraph siblings that follow an h2 with the same parent

For example, given this markup, nav > a matches the first link but not the nested link:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
<nav>
  <a href="/home">Home</a>
  <div><a href="/help">Help</a></div>
</nav>
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Combine selectors in a small, complete example

This example styles a page title, a reusable notice, and links inside navigation. The HTML makes the matching elements explicit:

<header>
  <h1>Account settings</h1>
  <nav>
    <a href="/profile">Profile</a>
    <a href="/security">Security</a>
  </nav>
</header>

<main id="main-content">
  <p class="notice">Your changes were saved.</p>
  <label>Email
    <input type="email">
  </label>
</main>
h1 {
  color: #183153;
}

nav > a {
  margin-inline-end: 1rem;
}

#main-content {
  max-width: 70ch;
}

.notice {
  padding: 1rem;
  background: #eef7ee;
}

input[type="email"] {
  border: 1px solid teal;
}

The class is reusable; the ID identifies a particular page region; and the child combinator keeps the navigation rule limited to direct links. Prefer selectors that communicate intent without depending unnecessarily on deeply nested markup.

Matching, specificity, and the cascade

Selector matching answers which elements a rule addresses. It does not by itself decide the final appearance when multiple declarations apply. The cascade resolves competing declarations, taking factors such as origin, importance, specificity, and source order into account.

Specificity is one part of that resolution: a type selector such as p is less specific than a class selector such as .notice, which is less specific than an ID selector such as #main-content. If rules conflict, first check whether both match the element, then inspect their cascade conditions and specificity. Avoid reaching for IDs or overly complicated selectors as a routine way to override styles; a reusable class is often easier to maintain.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing a selector

Selector choice Use it when Trade-off to consider
Type, such as button You want a broad default for that element type It affects every matching element unless constrained
Class, such as .notice You want a reusable style or component role The class must be present on the intended elements
ID, such as #main-content You need to target an element by its ID It is less reusable and has higher specificity than a class
Attribute, such as [type="email"] The attribute itself distinguishes the target A markup change to that attribute can change what matches
Pseudo-class, such as :hover You need to style a state or structural position Confirm the state is appropriate and the selector is supported
Combinator, such as nav > a The relationship in the document tree is meaningful Structural coupling can make a rule stop matching after markup changes

Check support before using newer selectors

CSS modules and selectors evolve. A selector appearing in a specification does not guarantee that every browser implements it, and a stable specification does not establish adoption. Consult MDN’s selector guide for current notes, including unsupported selectors, and test the exact feature in the browsers and versions your users need. For the broader status and snapshot framing, use the W3C specifications index and its CSS Snapshot 2025 explanation.

Or skip the browser setup

If your goal is to capture a webpage rather than learn CSS rendering, ScreenshotNeo provides a one-request screenshot API. For example, this cURL request saves a WebP screenshot of a page; replace the API key and target URL with your own:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for the API details. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.