HTML Checking for Large Sites
Rocket Validator automatically checks your pages on the W3C Validator.
The “border” attribute is obsolete. Consider specifying “img { border: 0; }” in CSS instead.
<img>
tags no longer accept a border
attribute. This can be defined using CSS instead, for example:
<img src="..." alt="..." style="border:0;" />
Related W3C validator issues
<img>
tags, used to include images on a document, require an alt
attribute to describe the contents of the image. This is essential for users that cannot see the image (like screen reader users), or as an alternate text when the image cannot be displayed. Example:
<img src="photo.jpg" alt="Person holding a cat" />
When an img
element has an empty alt
attribute, its role is implicitly decorative, so it must not specify a role
attribute.
Learn more:
The <table>
element does not accept a height
attribute. Use CSS instead.
A start tag for <img>
has been found inside a <noscript>
section within the <head>
, where it’s not allowed. Consider moving it to the <body>
section.
The HTML <noscript>
element defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.
When JavaScript is disabled, the content inside <noscript>
will be used instead, so this content must fit within its parent section. As an <img>
tag is not allowed inside <head>
, this will raise an issue. Instead, consider moving the <noscript>
part to the <body>
section.
This issue is often related to 3rd party tracking pixels like the Facebook or LinkedIn conversion tracking pixels. For example, the Facebook pixel instructions tell you to insert it like this:
<html>
<head>
<script>
...some script...
</script>
<noscript>
<img src="..." />
</noscript>
</head>
<body>
...
</body>
</html>
Instead, consider moving the <noscript>
part inside the <body>
, where the <img>
makes sense to be inserted:
<html>
<head>
<script>
...some script...
</script>
</head>
<body>
...
<noscript>
<img src="..." />
</noscript>
</body>
</html>
Learn more:
The src
attribute on an <img>
element contains an invalid character, that should be properly encoded as a URI percent-encoded character.
Learn more:
The src
attribute for <img>
tags is required, to define the source of the image, like in this example:
<img src="photo.jpg" alt="wombat" />
The attributes width
and height
of <img>
elements expect a non-negative integer, so an empty string is not allowed. Either define the correct dimension, or remove this attribute.
Learn more:
The src
attribute on an element <img>
contains a {
curly bracket character, which is not allowed unless properly encoded.
Space characters are not allowed in src
attributes. Instead, they should be converted to %20
. In this example, the first line is invalid and the second is valid:
<img src="https://example.com/?s=some term" alt="description" />
<img src="https://example.com/?s=some%20term" alt="description" />
The src
attribute on an element <img>
contains a character that is not allowed, and should be encoded.
Some typical examples include the pipe character |
that should be replaced by its encoded alternative %7C
, and the left square bracket [
that needs to be encoded as %5B
.
The src
attribute on an <img>
tag is not allowed to contain space characters. You should replace them with “%20
“.
The attributes width
and height
on <img>
elements define the dimensions of the image in CSS pixels, and expect a non-negative integer.
Learn more:
<img>
elements accept a width
attribute to specify the size in pixels. This value can only be an integer, it should not contain units or %
. If you need to specify a percentage width, you can do that with CSS:
<img src="photo.jpg" alt="red car" style="width:100%;">
The width
and height
attributes on <img>
and <iframe>
elements expect a digit to indicate the number of pixels. Ensure that this attribute contains only digits.
For example:
<!-- This is invalid because width is not a digit -->
<img width="225px" height="100px" alt="cat" src="cat.jpg" />
<!-- This is valid -->
<img width="225" height="100" alt="cat" src="cat.jpg" />
A CSS definition for background-image
could not be understood by the parser. Check its definition to ensure that it’s well formed and that it contains an appropriate value.
The value on the display
property is not valid.
The display CSS property sets whether an element is treated as a block or inline element and the layout used for its children, such as flow layout, grid or flex.
Learn more:
The specified CSS filter is not a standard one, and may only work in some browsers.
Check out the Filter Effects W3C Working Draft
font-display
isn’t a CSS property, it’s a descriptor for use with the @font-face
at-rule.
Learn more:
This issue is a false positive by the W3C validator, fixed in the latest versions of Nu Validator.
The value revert
is indeed a valid value for the CSS property font-size
.
Learn more:
The @import
CSS rule can be used to import a style sheet into another style sheet. It must appear at the top of the document, and after any @charset
declaration.
Learn more:
The max-width
CSS property sets the maximum width of an element. It prevents the used value of the width
property from becoming larger than the value specified by max-width
.
This property can express a value in different units like px
, em
, %
or ch
, and keyword values, but auto
is not an allowed value.
Some examples of valid values for max-width
:
/* <length> value */
max-width: 3.5em;
/* <percentage> value */
max-width: 75%;
/* Keyword values */
max-width: none;
max-width: max-content;
max-width: min-content;
max-width: fit-content(20em);
/* Global values */
max-width: inherit;
max-width: initial;
max-width: revert;
max-width: unset;
Learn more:
An invalid CSS property is being used. Properties starting with mso-
are commonly defined by Microsoft products like Office and Outlook.
These properties, like mso-spacerun
, mso-fareast-font-family
, mso-bidi-font-weight
, mso-margin-bottom-alt
, mso-margin-top-alt
and others starting with mso-
are not standard CSS properties.
Padding properties, unline margin properties, don’t accept negative values. Read more about the CSS box model
CSS styles could not be parsed, check the indicated line to find what caused the parser to fail. Common causes are unclosed curly brackets or comments, missing semicolons or unexpected or empty properties.
Read more about CSS: Cascading Style Sheets syntax
The value break-word
for the property word-break
is deprecated, you should replace it with a valid value.
According to the CSS Text Module Level 3 spec:
For compatibility with legacy content, the word-break property also supports a deprecated
break-word
keyword. When specified, this has the same effect asword-break: normal
andoverflow-wrap: anywhere
, regardless of the actual value of theoverflow-wrap
property.
Learn more:
The value specified for the transform
CSS attribute is not valid.
The transform
CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.
Learn more:
The ::file-selector-button
has not been recognized by the W3C Validator. This seems to be a bug in the W3C Validator, which has already been reported.
Learn more:
The value specified for a width
attribute in CSS is not valid.
The width CSS property sets an element’s width. There are many allowed values for this attribute, for example:
/* <length> values */
width: 300px;
width: 25em;
/* <percentage> value */
width: 75%;
/* Keyword values */
width: max-content;
width: min-content;
width: fit-content(20em);
width: auto;
/* Global values */
width: inherit;
width: initial;
width: revert;
width: unset;
Learn more:
CSS can’t be properly processed because a computed style is missing a value it depends on.
A CSS definition for an X property could not be understood by the parser. Check it to ensure that it’s well formed and that it contains an appropriate value.
<img>
tags used to display images require the attribute src
to indicate the source of the image, for example <img src="/img/photo.jpg" />
.
When specifying a numeric value for a CSS property, remember to always include the units, like 3px
or 3em
. Only the 0
value can go without units, and instead of 0px
you can just use 0
.
Learn more:
<td>
elements no longer accept an align
attribute. This can be achieved using CSS like this:
<td style="text-align:center;">content</td>
The <big>
tag is now obsolete. It was used to increase the size of text, you can do that using CSS instead. For example:
<p>Now this is <span style="font-size: larger;">big</span></p>
Read more:
The <center>
tag is no longer valid in HTML, you should use CSS instead, for example:
<p style="text-align:center">this text will be centered</p>
The <font>
element, used to define the font face, size and color in previous versions of HTML, is no longer valid in HTML5. Instead, you should rely on CSS styles.
For example, you can define a font size of 12px, bold text with inline styles like this:
<p style="font-size: 12px; font-weight: bold;">some text</p>
Learn more about CSS fonts:
A single <img>
element is used to embed an image, so adding the img
role to it is redundant.
The ARIA img role can be used to identify multiple elements inside page content that should be considered as a single image. These elements could be images, code snippets, text, emojis, or other content that can be combined to deliver information in a visual manner, for example:
<div role="img" aria-label="Description of the overall image">
<img src="graphic1.png" alt="">
<img src="graphic2.png">
</div>
Learn more:
The <tt>
tag, used in HTML4 to apply a monospaced (fixed width) font to the text, was deprecated in HTML5. Instead, you should use CSS to apply the desired font.
Example, instead of this deprecated code:
<tt>This is deprecated</tt>
You can define a monospaced text using font-family
:
<span style="font-family: monospace;">This is monospaced text</span>
Learn more:
The HTML <style>
element contains style information for a document, or part of a document, defined in CSS. This element does not need the type
attribute anymore, so it should be omitted.
For example, this style defines that <p>
elements should be in red color.
<style type="text/css">
p {
color: red;
}
</style>
<p>This text will be red.</p>
But, the type
attribute is not used anymore, so we can just use this:
<style>
p {
color: red;
}
</style>
<p>This text will be red.</p>
Read more:
MDN: The Style information element WordPress plugin: Type Attribute Warnings Removal
<td>
elements no longer accept a valign
attribute. This can be achieved using CSS like this:
<td style="vertical-align:middle;">content</td>
Both <table>
and <td>
elements no longer accept a width
attribute. Instead, you should use CSS as in this example:
<table style="width:100%;">
<tr>
<td style="width:50px;">Name</td>
</tr>
</table>
You’re using an attribute X that is no longer valid for element Y, but you can use CSS to achieve the same effect.
Check the HTMLImageElement.srcset guide to learn about the correct usage of the srcset
and sizes
attributes.
When was the last time you validated your whole site?
Keep your sites healthy checking for A11Y/HTML issues on an automated schedule.