Skip to main content
Participant
June 28, 2019
Question

Erreur code

  • June 28, 2019
  • 2 replies
  • 1293 views

Bonjour,

Je suis en cours de développent d'un site web. Il est affiché qu'il y a deux erreurs mais je ne sais pas comment faire pour les résoudre:

  1. The attribute [ href ]  of the tag [ link ] must have a value.
  2. An alt attribute must be present on <img> elements

Merci d'avance pour votre aide.

_______________________________________________

Hello,

I am in the process of developing a website. It is displayed that there are two errors but I do not know how to solve them:

  1. The attribute [ href ]  of the tag [ link ] must have a value.
  2. An alt attribute must be present on <img> elements

Thank you in advance for your help.

This topic has been closed for replies.

2 replies

BenPleysier
Community Expert
Community Expert
June 28, 2019

Running the following code through the HTML checker

<!doctype html>

  <html lang="en"><head>

    <meta charset="UTF-8">

    <title>Untitled Document</title>

  </head>

  <body>

    <a href="">About Me</a>

    <img src="img/wappler-logo.png">

    <a class="arrow"></a>

  </body>

</html>

I get the following error

What does this mean?

  1. (The attribute [ href ]  of the tag [ link ] must have a value.) is not an error. But at the same time, both anchor tags in my example are not true hyperlinks. A true hyperlink contains a valid hyperlink reference ( [ href ]) attribute, i.e. contains a URI.
  2. HTML 5 does not specify that an [ alt ] attribute is a must. Hence, the [ alt ] attribute need not be used. However the specification goes on to say:
    The HTML5 specification requires conformance checkers to report the lack of an alt attribute as an error, except in certain cases; for details, see the Guidance for conformance checkers subsection of the Requirements for providing text to act as an alternative for images section of the spec.

    Authoring useful alt attribute content requires the author to carefully consider the context in which the image appears and the function that image may have in that context. For guidance on writing text alternatives refer to the Requirements for providing text to act as an alternative for images section of the spec


    This means that the checker needs to report the lack of an [ alt ] attribute; but is technically not an coding error.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Legend
June 28, 2019

BenPleysier  wrote


  1. HTML 5 does not specify that an [ alt ] attribute is a must. Hence, the [ alt ] attribute need not be used. However the specification goes on to say:
    The HTML5 specification requires conformance checkers to report the lack of an alt attribute as an error, except in certain cases; for details, see the Guidance for conformance checkers subsection of the Requirements for providing text to act as an alternative for images section of the spec.

    Authoring useful alt attribute content requires the author to carefully consider the context in which the image appears and the function that image may have in that context. For guidance on writing text alternatives refer to the Requirements for providing text to act as an alternative for images section of the spec



The alt attribute is mainly for the purpose of screen readers, it also might server a purpose for images that dont automatically load such as when building an email template.  Its not a coding error but its always 'polite' to add if there is something descriptive that could enhance the website for those at a disadvantage visually. As it requires zero extra time its good to just get into the habit of making sure one is present, regardless of what the w3c's take on it is, technically.

BenPleysier
Community Expert
Community Expert
June 28, 2019

That is why I included the link to Requirements for providing text to act as an alternative for images​ which states

It is important what W3C's take is.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Legend
June 28, 2019

1) You have empty  anchor links:

<a href="">About Me</a>

Either add a link:

<a href="about_me.html">About Me</a>

or add #

<a href="#">About Me</a>

2) An alt attribute should be declared on all of your img tags:

<img src="rabbit.jpg" alt="Brown rabbit on grass">

or if its a non descriptive image:

<img scr="bullet.jpg" alt="">

Participant
June 28, 2019

Merci pour votre aide.

J'ai deux autres problèmes avec mon fichier css:

  1. Expected RBRACE at line _, col _
  2. Unexpected token '{' at line _, col _

___________

Thanks for your help.

I have two other problems with my css file:

Expected RBRACE at line _, collar _

Unexpected token '{' at line _, collar _

BenPleysier
Community Expert
Community Expert
June 28, 2019

léor38304831  wrote

Thanks for your help.

I have two other problems with my css file:

Expected RBRACE at line _, collar _

Unexpected token '{' at line _, collar _

It would have helped if you had shown the complete code because then we could have told you exactly where the braces do not match.

Always keep in mind that a left brace requires a corresponding right brace.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!