Does a CSS Gradient Background Count Toward LCP in Core Web Vitals?
An element painted only with CSS linear-gradient() or background-color is not counted as the Core Web Vitals LCP (Largest Contentful Paint), even when it covers about the top half of the screen. On the page I tested, the LCP was the heading below it, with values of 32 to 92ms. When the same gradient was set as a background using url() to an image file, that box became the LCP, with values around 836ms, which is when the image was displayed. (In the test, the server waited 800ms before returning the image.)
This can help you estimate how LCP values change when you replace the hero area of a top page (the large heading area at the top) with a gradient or solid background instead of an image. It is also useful when PageSpeed Insights or Lighthouse shows a heading as the LCP element instead of the largest-looking background and you can't tell why.
The test environment was Ubuntu 24.04, Node.js 22.23.4, web-vitals 6.2.3, Playwright 1.63.0, and Lighthouse 13.6.0. I used the Chromium 153 bundled with Playwright in headless mode. The page was served from a server written with Node.js's http module at localhost:8080. Only the image was made to wait 800ms before the server returned it. I set the Playwright viewport to 412×823 and measured each page three times. I did not test browsers other than Chrome, PageSpeed Insights, or real user data (CrUX).
The rules for what counts as an LCP element
The LCP explainer on web.dev lists the types of elements that can be LCP candidates: <img>, <image> inside <svg>, <video> (its poster image or first frame), block elements containing text, and elements with a background image loaded with url(). The background image item includes a note in parentheses that CSS gradients are not included.
The same explainer also describes elements that Chromium-based browsers exclude: elements with opacity set to 0, elements that cover the whole screen and are treated as backgrounds, and placeholder images that have low information content (low entropy) and do not represent the page's content.
Gradient and background-color boxes were not counted
The test page had a box (div.hero) 360px tall at the top, followed by a heading and a short sentence. I varied the contents of the box and made eight versions of the page. The table below shows the results for seven of them. The version with a heading inside the box is covered in the next section.
<style>
.hero { display: block; width: 100%; height: 360px; }
.hero { background: linear-gradient(135deg, #00c8e8, #eefafd); } /* Change this line for each page */
</style>
<div class="hero"></div>
<main>
<h1>記事の見出し</h1>
<p>本文の短い文章です。</p>
</main>
To measure, I recorded all largest-contentful-paint entries with PerformanceObserver, and also received the final value and element from onLCP() in web-vitals. The results are below (values from three runs).
| Box background | web-vitals LCP | LCP element |
|---|---|---|
linear-gradient(135deg, #00c8e8, #eefafd) |
92 / 36 / 32ms | Heading (h1) |
background-color: #00c8e8 |
32 / 44 / 32ms | Heading (h1) |
Single-color PNG via url() |
28 / 28 / 32ms | Heading (h1) |
Single-color PNG via <img> |
36 / 44 / 32ms | Heading (h1) |
Gradient PNG via url() |
836 / 836 / 836ms | Box (div.hero) |
Patterned JPEG via url() |
844 / 836 / 840ms | Box (div.hero) |
JPEG with stacked linear-gradient() via url() |
836 / 840 / 836ms | Box (div.hero) |
On the pages with gradient and background-color boxes, only one entry was recorded, the heading. The box area was 412×360 (size 148,320), more than 20 times the heading's size of 7,020, but it was not a candidate at all.
On the pages where the background was an image file, the heading was a candidate first (28 to 48ms). Around 836ms, when the image was displayed, the LCP moved to the box, whose size was 148,320. The approach of overlaying a semi-transparent black linear-gradient() on top of a photo also resulted in the JPEG below as the LCP URL, and the box became the LCP.

The image shows the page with the CSS gradient and the page with a gradient PNG as the background. In each, I outlined in pink the element that web-vitals returned as the LCP. Both look like gradient backgrounds, but the LCP elements and values differ greatly. In this measurement, the LCP of the PNG page was 828ms.
Placing a heading inside the box: only the text area is counted
I also measured a page with a heading placed in the center of the gradient box. The LCP values were 32 / 32 / 36ms, and the element was the heading inside the box (div.hero>h1).
The size here was 7,056, almost the same as the 7,020 for the heading placed outside the box. As the LCP explainer describes, text elements are compared by the size of the smallest rectangle containing all their characters. The area of the gradient background is not added.
Even single-color images gave different results depending on the file
A single-color PNG (1200×675, 272 bytes) was not counted as the LCP, whether it was set with url() as a background or displayed with <img>. Even though the image was loaded and displayed, the only entry was the heading. The LCP explainer describes excluding low-entropy images, but it does not give a specific criterion for which images qualify.
However, not every image that looks like a single color was excluded. I measured three times each for backgrounds of the same size (1200×675) with different content. The table is sorted by file size, smallest first.
| Background image | File size | LCP element |
|---|---|---|
| Single-color PNG | 272 bytes | Heading (all 3 runs) |
| Light blue and white checkerboard PNG | 2,084 bytes | Box (all 3 runs) |
| Gradient PNG (8-bit) | 4,156 bytes | Box (all 3 runs) |
| Single-color JPEG (quality 50) | 5,124 bytes | Box (all 3 runs) |
| Gradient PNG (16-bit) | 6,886 bytes | Box (all 3 runs) |
| Single-color JPEG (quality 100) | 9,851 bytes | Box (all 3 runs) |
The single-color JPEGs became the LCP box at both quality 50 and quality 100. The values were 832 to 844ms, which is again the time the image was displayed. So even a background that looks like one color can be counted as an LCP element if it is loaded as an image file. With only these six types, I could not determine where the line is drawn.
Lighthouse also showed the heading as the LCP element
I also measured three pages once each with Lighthouse 13.6.0's default mobile settings. The table shows the observed LCP value from the metrics audit in the JSON, and the LCP element taken from the lcp-breakdown-insight audit.
| Box background | Observed LCP (observedLargestContentfulPaint) |
LCP element |
|---|---|---|
linear-gradient() |
83ms | body > main > h1 (380×32) |
Single-color PNG via url() |
65ms | body > main > h1 (380×32) |
Patterned JPEG via url() |
865ms | body > div.hero (412×360) |
As with the web-vitals measurements, the heading was the LCP element on the gradient and single-color PNG pages, and the box was the LCP element on the patterned JPEG page. When a Lighthouse report shows a heading as the LCP element instead of the largest-looking background, check whether that background is a CSS gradient or background color, or a single-color image.
After you replace a hero background that was an image file with a CSS gradient or background color, use web-vitals or Lighthouse to check what the LCP element has become. The background drops out of the candidates, and the next largest element, such as a heading, becomes the LCP.





