1

The following code was found on a website. Is it valid HTML?

<td><a href=http://dummy.url/example.pdf target="_blank"</a> Example</td>

Example is not clickable using older browsers but is with newer ones. Wouldn't code below be better?

<td><a href="http://dummy.url/example.pdf" target="_blank"> Example</a></td>
1
  • 1
    Text after an anchor tag is perfectly valid. It will result in a link of zero width (thus completely invisible). The opening tag, however, needs to be closed properly: <a href="#"></a> Example
    – Midas
    Jun 12, 2016 at 13:14

4 Answers 4

1

No. There is a missing > for the start tag. Notice the code highlighting is broken in your first example. Different browsers "correct" incorrect HTML in different ways.

You can attempt to validate it here:

https://validator.w3.org/#validate_by_input

0

The first code is invalid, some browsers can render it but this not mean that it's valid.

0

Below code in your question is valid HTML code. It should work on all browsers. There is no error in above second line of code

-2

I dont know much but i think the href should be in quotes since it should be string, as for the text after anchor i never tried it before.. I dont know if it has something to do with the target element referring to other element with name blank though cant test it on phone

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.