2

I have 2 questions:

  1. As W3C can we add onclick inside <li> tag?

  2. Will this affect anything to do with SEO?

For example:

<li onclick="newDoc()">Click!</li>

function newDoc() {location.assign("http://validator.w3.org/");}

1 Answer 1

3

As far as I know, inline JavaScript is a no no. You seperate your HTML, PHP, CSS and JS files into different files. Inline styling/coding only makes bad maintainable code. You'll forget where you did what, and debugging will become a pain in the ass.

For SEO, if your pages are HTML(x/5) valid, no problems. As long as you don't expect them to run JavaScript (e.g.: show content only after click).

Yes, there are some situations where inline style/coding is OK, but they're exceptions.

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.