Firstly, while stackOverflow has helped me many times before, this is my first ever posted question. Thus, please be gentle (I'm still new to coding) and provide any suggestions if I am doing something wrong in regards to stackOverflow protocol :-)
My issue:
I am trying to w3c validate my code using the Nu Html Checker and I keep running into a similar issue in many pages and can't yet find a solution.
It has to do with issues with my Google Analytics Event Tracking using onclick.
Here are the repeated error messages I am getting from the validator:
- Error: No space between attributes.
- Warning: Attribute ; is not serializable as XML 1.0.
- Warning: Attribute false; is not serializable as XML 1.0.
- Error: Attribute ; not allowed on element a at this point.
- Error: Attribute return not allowed on element a at this point.
- Error: Attribute false; not allowed on element a at this point.
ALL these errors are occurring on Line 174.
Here is the Line 174 code I am using:
<h2><b><a href="free.html" onclick="ga('send','event','outbound','click', 'foundations')" target="_self"; return false;>Click Here to Access</a></b> for <b>Free</b>.</h2>
Now, I know in theory that I could probably solve this by removing ; return false;
but I'm concerned this will kill my Event Tracking in Google Analytics (as as far as I am aware you need return false;
to trick link click events, especially when they take you to an external site (which some other pages with similar errors do).
So:
- How do I solve these w3c Validation errors,
- While still tracking Google Analytic Events?
Thanks for any and all help, Axel
; return false;
and everything still works as planned. Valid HTML, Event was tracked & link worked fine. Thanks @lucas for your response, you put me at ease after my first question! Just a bit silly that I finally get the courage to post a question (after spending hours trying to solve this), and it gets solved within 30-mins by doing the thing that I originally said couldn't be done :-/ Thanks all!