Welcome to another article on Building Better Web Pages. This article series comprehensively covers building an HTML document: easily learned, but rarely perfected.
Why is it Important?
<input type="text" name="somename" onclick="dosomething();" />
Consider the previous code example. This time, however, we will be passing the input element in the form of some variable “x.”
<input type="text" name="somename" onclick="dosomething(x);" />
We like using our function, so it appears numerous times across numerous files. This presents a huge maintenance problem. One day we need to make some changes to the method and now require a different variable or use a new function name. The only way to handle the situation now is to search through all the files and make changes in every one.
For building better web pages, any of the following books are a great! “Web Design For Dummies” introduces pretty much every aspect of design, including planning and research. If you are interested more in the concepts and ideas of proper markup, go with “HTML and CSS Web Standards Solutions”. Finally, for a more conversational tone, “Designing with Web Standards” is reading geared toward the practical application, rather than the concepts themselves.
Sorry, but I fail to see how you’ve made any relevant point here. Your assumption is that one wishes to do what you’re mentioning, which for most applications other than social media sharing.
No offense or anything, I just keep hearing that this is “bad”, but I don’t see any real reasons why so far other than these fringe cases.
No offense taken. I just reread this article and it still applies as much today as it did a year ago.
This comes up everywhere in my work, whether it’s commercial websites, freelance stuff, or enterprise web applications, so it matters all across the board. I made a whole lot of good points and don’t see how you wouldn’t find them relevant. Your sentence about social media has a typo so I don’t understand what you are trying to say.
I would ask you what your motivation is for looking this up? Is there some reason you wouldn’t want to do this? At the end of the day, it’s simply best practice. If you want to write bad code for whatever reason, that’s up to you.
Other people’s bad code just makes mine look better
Href has been removed here, since href is obviously behavioral and doesn’t really have anything to do with the markup. And then you would know to look elsewhere to figure out what that link does. The worst case is to have something like this:
And then in a separate file:
Bryan, I think the comment system stripped out some code you had in there.
I can still see, though, that you are making the argument for readability. I contend that would be incredibly minor compared to the code modularity and maintenance ease provided by unobtrusive scripting, especially when today’s IDEs can easily take you to connecting code without knowing where it is. Also you were making some connection between navigation (href) and scripting (events), which are fundamentally and semantically different.