This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
We all used <br> along time ago and then for a long time also <br /> over <br/>
Does HTML5 defines that empty elements should not be closed?
I mean should we use <br> and <img src="" alt=""> again with no closing slash?
Thanks in advance,
Is there a recommendation - w3c or whatever? O'Reilly School of Technology told me that empty elements shouldn't be closed?
I would say without slash it is simpler, faster, but most of the web today closes the empty tag?
What are You using?
--->thanks, I just read Your post
A few more of my person style choices: I always use all lowercase (nothing makes HTML less readable and more like it's from 1998 than using all uppercase), and I always quote attribute values whether they need it or not.
Essentially, all my style choices come down to what I feel gives the markup the greatest degree of clarity and readability.
Joined: Nov 13, 2008
Is there a difference when using single or double quotes? like <img src="" alt=''>
Is it true that both works equally? I prefer double quotes. Thanks,
At the moment it's personal preference. There's nothing that says you should or should not close empty elements like <hr>, <br>, <input>, etc. With that said, as a general rule of thumb, I no longer use the trailing forward slash on empty elements. The rule is a hold over from XHTML and it has always bothered me. The trend in HTML is to remove as much markup as you can from the document (either by eliminating unnecessary code, using lighter HTML5 syntax, differing to CSS (and CSS type selectors) whenever possible, etc.) as possible...obviously to improve load time, page-to-page browsing efficiency, and footprint on mobile devices. It always seemed to me that adding the unnecessary forward slash was just....well...unnecessarily bloating the size of the page by adding characters that were not needed. When HTML5 was in its infancy...there was a debate about whether or not to continue on with the main XHTML rules (lowercase tags, close all attribute values in quotes, close empty elements, add the value to Boolean attributes (example <input type="text" disabled="disabled">. Long story short, for a while we had what was referred to as "polyglot HTML5" which was HTML5 using syntax rules of XHTML. More and more the trend is going away from this and back to the old writing style of HTML 4.
Joined: Nov 13, 2008
So I don't even need to use multiple="multiple", i just multiple enough?
Yes, just multiple is enough. The rest is redundant and needless. And, in fact, very confusing. That's always bothered me about xhtml.
Take for example something I've seen a lot of: the disabled attribute expressed as disabled="true". That will work just fine to disable the element. But that leads one to believe that disabled="false" will not disable the element. But it does. Why? Because in xhtml, the value doesn't matter, there just needs to be one to satisfy XML rules. It's the presence of the disabled attribute with any value that disables the element. It's much clearer to just have disabled.