Enter a reason for deleting this comment
Let's say you write invalid HTML code. Will it still work? If so, why would it work if it's invalid?
That will really depend on what you mean by 'work'. If by work you simply mean display what you have done then yes it will, it won't show an error and nothing else like it may when working with another language like PHP for example. Being that HTML is a markup language there's no reason it would work any differently that it does.
If you have a image on a website in the IMG tag and no ALT attribute it is marked as invalid by W3 Validator the image will still display but it is marked as invalid. The smallest mistake can make a HTML element / node / tag invalid it all depends on how invalid the HTML is to determine if it works.
It's not like the code will work or not. Whichever tags are valid they will be compiled and displayed and the ones that are incorrect will not.