Game Development Reference
In-Depth Information
this.value='';
}" />
Of course, there are many ways to achieve this same effect using JavaScript. In
HTML5, this same feature, called placeholder, can be achieved with a single line of
code, as shown in the following code snippet:
<input type="text" placeholder="Last Name" />
The reason that this second version works is because the attribute placeholder was
added to the browser, as well as the logic required to make it work. While this may
seem like a nice little trick that the browser has learned, let's take a closer look at
some of the main benefits this provides us with:
• You, as the developer, have potentially hundreds fewer lines of code
to write and test throughout the course of your entire project, since the
browser exposes such a simple alternative
• Development time decreases for two reasons: you have less code to
write, and you have less code to test
• Your code will be more portable and reliable, since you don't need to write
specific implementations of your code logic for each browser, and you
can trust that each browser will implement the feature properly (even if it
takes a couple of updates for them to get there)
In other words, instead of putting a lot of your efforts into normalizing your code so
it runs the same way in as many browsers as possible, or writing a lot of boilerplate
code just to bring your application to the latest accepted standards, you can now in-
vest the majority of your time building unique applications, since the repetitive code
is abstracted away by the browser.
One last exciting point about this positive cycle of HTML5 that I'd like to point out
is, how, since HTML5 is responsive to common use cases and real world needs,
as time goes by we can only expect more and more really neat and useful features
being added to the browser natively. Who can even imagine what new features the
browser will support natively in the next few years?
Search WWH ::




Custom Search