HTML Guide
The gap
property in CSS does not accept auto
as a valid value.
The gap
property is used with CSS Grid and Flexbox layouts to define the spacing between grid tracks or flex items. Acceptable values for gap
include length values such as px
, em
, %
, or keywords such as normal
. The value auto
is not valid for the gap
property; instead, use valid length units or the normal
keyword.
Correct usage:
<div style="display: grid; gap: 16px;">
<div>Item 1</div>
<div>Item 2</div>
</div>
Incorrect usage (produces a validation error):
<div style="display: grid; gap: auto;">
<div>Item 1</div>
<div>Item 2</div>
</div>
For responsive or dynamic spacing, set the gap
property to a valid length (e.g., 1rem
, 10px
, 5%
) or use media queries to adjust spacing at different breakpoints.
Learn more:
Related W3C validator issues
The height attribute on the <video> element must be a non-negative integer representing the height in CSS pixels. The value “auto” is not a valid value for this attribute. To resolve the issue, set the height attribute to a specific numeric value or adjust the height using CSS instead.
Example with a numeric height value:
<video width="640" height="360" controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
Alternatively, control the height using CSS:
<video width="640" controls style="height: auto;">
<source src="movie.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
In the CSS approach, “auto” can be used, but it should not be part of the HTML attributes.
The width and height attributes on <img> elements expect a digit to specify the dimension in pixels. It should not contain units, letters or percent signs.
You can achieve this using CSS instead, for example:
<!-- Invalid syntax, the height attribute expects only digits -->
<img src="photo.jpg" alt="cat" height="auto" />
<!-- Valid syntax using CSS -->
<img src="photo.jpg" alt="cat" style="height: auto" />
The sizes attribute specifies the size of the image when it is displayed on different devices.
The error message is saying that the value auto is not a valid value for the sizes attribute.
To fix this issue, you need to replace the value auto with a valid size. You can use a width descriptor or a media query to specify the size for different device widths.
Here’s an example of using a width descriptor:
<img src="example.jpg" sizes="(max-width: 600px) 100vw, 50vw" />
This example sets the size of the image to 100% of the viewport width when the device width is less than or equal to 600px, and 50% of the viewport width for larger device widths.
Alternatively, you can remove the sizes attribute altogether and let the browser decide the best size for the image based on the viewport size.
<img src="example.jpg" />
If you do this, the browser will use the default sizes value of 100vw and will scale the image accordingly.
The width attribute on the img element must be a positive integer representing the number of pixels.
The HTML img element’s width and height attributes are expected to specify image dimensions in pixels. According to the HTML Living Standard, these attributes accept only non-negative integers. These integers define the rendered dimension of the image, overriding the actual image size based on its native resolution. The value “auto” is not a valid integer, which leads to the validation error you’ve encountered.
Here is a correct usage example of the img element:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Valid Image Width</title>
</head>
<body>
<img src="example.jpg" alt="Example image" width="200" height="100">
</body>
</html>
In the example above, the width is set to 200, and the height is set to 100. Both values are non-negative integers representing pixel dimensions. If you intend to maintain the image’s aspect ratio while adjusting another dimension, you can omit one of the attributes, and modern browsers will automatically adjust the aspect ratio based on the given dimension.
The error message is indicating that the width attribute of the <video> element has an invalid value. According to the HTML specification, the width attribute expects a non-negative integer value, representing the pixel width of the video.
The value "auto" is not valid for the width attribute. Instead, specify a full number that indicates the pixel width of the video. If you want the video to be responsive without specifying a fixed width, you can use CSS to achieve that.
Here are two ways to resolve this:
-
Specify a valid pixel value for width:
<video width="640" height="360" controls> <source src="video.mp4" type="video/mp4"> Your browser does not support the video tag. </video>
-
Use CSS for a responsive video player:
Instead of using the width attribute, use CSS to set the width of the video element. This allows the video to adjust its size according to the container or viewport.
<style> .responsive-video { width: 100%; height: auto; } </style> <video class="responsive-video" controls> <source src="video.mp4" type="video/mp4"> Your browser does not support the video tag. </video>
In the second example, the video will scale based on its containing element, maintaining its aspect ratio due to the height: auto; CSS rule. This approach offers more flexibility for responsive design.
background-blend-mode only accepts certain keywords as values, such as normal, multiply, screen, and others.
The background-blend-mode property in CSS specifies how background images and background colors blend together. Its value must be one or more blend mode keywords defined by CSS, for example, normal, multiply, screen, overlay, etc. Using an unrecognized value will generate a validation error.
Valid values include:
- normal
- multiply
- screen
- overlay
- darken
- lighten
- color-dodge
- color-burn
- hard-light
- soft-light
- difference
- exclusion
- hue
- saturation
- color
- luminosity
Example of an invalid value:
/* Invalid: 'X' is not a recognized value */
background-blend-mode: X;
Example of a valid value:
/* Valid: 'multiply' is a recognized blend mode */
background-blend-mode: multiply;
Example HTML with correct CSS property:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Background Blend Mode Example</title>
<style>
.blended-bg {
background-image: url('image1.jpg'), url('image2.jpg');
background-blend-mode: overlay;
}
</style>
</head>
<body>
<div class="blended-bg" style="width:200px; height:200px;">
Blended background
</div>
</body>
</html>
Replace any invalid values for background-blend-mode in your CSS with one of the supported keywords.
background CSS property has an invalid value; "from" is not recognized as a valid color or background value.
The background property in CSS can accept color names, hex codes, rgb/rgba values, or CSS keywords, but "from" is not valid. Sometimes this error can appear if using incorrect CSS gradient syntax, where "from" is not a recognized value.
Detailed Explanation
In standard HTML and CSS, a background can be set using:
- Hex color codes, such as #fff or #ffffff
- Named colors, such as red or blue
- Functions, such as rgb(255,0,0) or linear-gradient(...)
If you wrote something like:
background: from #fff to #000;
or
background: "from";
neither is valid CSS.
To use gradients, use correct linear-gradient() or radial-gradient() syntax:
background: linear-gradient(to right, #fff, #000);
For a solid color:
background: #fff;
HTML Examples
Incorrect CSS:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Incorrect CSS</title>
<style>
div {
background: from #fff to #000; /* Invalid syntax */
}
</style>
</head>
<body>
<div>Bad background</div>
</body>
</html>
Correct CSS (Gradient):
<!DOCTYPE html>
<html lang="en">
<head>
<title>Correct CSS Gradient</title>
<style>
div {
background: linear-gradient(to right, #fff, #000);
}
</style>
</head>
<body>
<div>Good background</div>
</body>
</html>
Correct CSS (Solid Color):
<!DOCTYPE html>
<html lang="en">
<head>
<title>Correct CSS Color</title>
<style>
div {
background: #fff;
}
</style>
</head>
<body>
<div>White background</div>
</body>
</html>
Always use a valid color value or gradient function for the background property.
background-image attribute values must use valid CSS syntax.
The background-image property in CSS expects the value to be a valid image reference, such as none, url("image.png"), gradients, or inherit.
Correct CSS Syntax:
background-image: url("background.jpg");
Correct usage in HTML (inline style):
<div style="background-image: url('background.jpg');">
Content here
</div>
Incorrect usage (missing url() or filename only):
<div style="background-image: background.jpg;">
Content here
</div>
Correct usage in a <style> block:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Background Image Example</title>
<style>
.banner {
background-image: url("banner.png");
}
</style>
</head>
<body>
<div class="banner">Welcome</div>
</body>
</html>
Always wrap the image path with the url() function and use quotes for paths containing special characters.
Use the correct direction keyword syntax in CSS gradients: replace top with to top.
In CSS Images Level 4, the first argument of linear-gradient() should either be an angle (e.g., 180deg) or a direction using the to keyword (e.g., to top, to right). Older syntax like linear-gradient(top, ...) is no longer valid and triggers validator errors. Valid forms include: linear-gradient(to top, #fff, #000), linear-gradient(180deg, #fff, #000), or simply omit the direction to default to to bottom. Keep gradients in your CSS, not HTML attributes. The style attribute or a stylesheet can set the background or background-image with a valid gradient function.
HTML Examples
Example showing the issue
<!DOCTYPE html>
<html lang="en">
<head>
<title>Gradient Issue</title>
<style>
.box {
width: 200px;
height: 100px;
background: linear-gradient(top, #ffffff, #000000); /* invalid */
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
Fixed example (valid syntax)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Gradient Fixed</title>
<style>
.box {
width: 200px;
height: 100px;
/* Option A: direction keyword */
background: linear-gradient(to top, #ffffff, #000000);
/* Option B: angle (equivalent) */
/* background: linear-gradient(0deg, #ffffff, #000000); */
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
There’s an invalid value for the background property in your CSS. The W3C HTML Validator has attempted to match the value to a background color, without success.
Here’s how to resolve this issue:
-
Identify the Correct CSS Configuration: The background property in CSS can take various forms, such as a color, an image, or a combination of background components. Ensure you provide a valid value.
-
Correct the Value: If you meant to set a background color, use a valid color format (e.g., hexadecimal, RGB, RGBA, named color, etc.).
Valid CSS Examples:
-
Using a named color:
.example { background: blue; }
-
Using a hexadecimal color:
.example { background: #00ff00; }
-
Using an RGB color:
.example { background: rgb(255, 0, 0); }
-
Using an RGBA color (with transparency):
.example { background: rgba(255, 0, 0, 0.5); }
-
Setting an image as background:
.example { background: url('image.jpg'); }
-
Combining multiple background properties:
.example { background: url('image.jpg') no-repeat center/cover; }