Hot answers tagged

561

Update: this answer seems to be pretty popular so I took some time to clean it up a little bit, add some new info and clarify few things that I thought were not clear enough. Please comment if you think anything else needs clarification or updates. Most of your concerns are really a matter of opinion and personal preference but I'll try to answer as ...


203

This is a fascinating question. The other answers here are all speculative, and in some cases flat-out incorrect. Instead of writing my opinion here, I actually did some research and found original sources that discuss why delete and put are not part of the HTML5 form standard. As it turns out, these methods were included in several, early HTML5 drafts (!), ...


122

The question is if the data is semantically a table (i.e. a set of data or units of information logically organized in two dimensions) or you just use the grid for visual layout, e.g. because you want a sidebar to expand or something like that. If your information is semantically a table, you use a <table>-tag. If you just want a grid for layout ...


117

Specification says UNIQUE HTML 4.01 specification says ID must be document-wide unique. HTML 5 specification says the same thing but in other words. It says that ID must be unique in its home subtree, which is basically the document if we read the definition of it. Avoid duplication But since HTML renderers are very forgiving when it comes to HTML ...


97

Free Functionality Properly using <label>s means you can click the label to enter the text field. Many browsers will add logical default functionality to many tags per the official specification, meaning you can use fewer JavaScript plugins and write less code than a site made entirely out of <div>s and <span>s. Accessibility Related to ...


94

Because saving HTTP requests is of little use when you achieve it by breaking caching. If the stylesheets and scripts are served separately, they can be cached very well and amortized over many, many requests to wildly different pages. If they're mushed in the same HTML page, they have to be re-transmitted with every. Single. Request. This page's HTML, for ...


87

Last summer, I read the complete HTML5 specification, and every previous HTML specification (even the abandoned ones), and all CSS specs I could find, and a lot of XML specs. Since I love semantically rich hypertext documents, let me give you the idea behind the relevant HTML semantics in HTML5. Before HTML5 Before HTML5, i and b were indeed deprecated. ...


84

HTML and CSS are difficult to interview for a few reasons: They are too basic, compared, for example, to a programming language, They depend very much on the context of the job. Examples: If you create Google scale, hugely fast and optimized websites, the people you interview for the job cannot ignore what CSS sprites are. If you create XHTML W3C valid ...


84

Actually, I would say that the use of class names like "table" in your example demonstrates how people don't actually understand what they're doing when trying for semantic markup. They get marks for trying to show that the content is not tabular data, but they lose marks for bad class names. <div class="table"> <div class="row"> <div ...


76

I believe you are looking at the problem the wrong way - you are missing a great opportunity of teaching the juniors how to write better code. If you habitually re-write their code, you might give your juniors the impression that you don't value their work, which will lower their morale, and not help them code better the next time. A better approach, I ...


70

You should build a house first, then paint it. An HTML document can stand on its own, even though it may look dull. A CSS style sheet cannot; it is nothing displayable (except as code) but instructions for display. It’s a different issue that during painting, you may wish to do changes to the house. With real houses that’s usually not feasible, but in ...


55

As Doval says, they are not deprecated. They still exist but should be used differently from what many people where used to before HTML5. It's about 'semantic' html. It should describe 'what' it is, instead of how it should look. The browser or theoretically any other display medium (say a reading app for the blind) should be able to decide how exactly ...


52

HTML5 is not a single integrated thing. It's a collection of extensions to HTML, some of which are widely-implemented and can be used safely, some of which no-one implements yet, and a whole lot in-between. If you try to treat HTML5 as a coherent single development platform and ‘learn it all’ you will have a really difficult time. Instead what you need to ...


50

No, this is not a good practice. You should use already semantic, meaningful tags -- perhaps <em> in this case -- and apply CSS styles to achieve your design requirements.


46

This is a common pattern for making responsive tables. Tabular data is tricky to display on mobiles since the page will either be zoomed in to read text, meaning tables go off the side of the page and the user has to scroll backwards and forwards to read the table, or the page will be zoomed out, usually meaning that the table is too small to be able to ...


42

If I were to start a new HTML5 project from scratch right now I would probably do something like this: Download and use the HTML5 Boilerplate. This will give you a fresh page with most of the important things initialized and ready for testing. Also includes some nice debugging features you should be using along with firebug Look over Dive in to HTML5 to ...


36

To directly answer your question: Never echo static text or HTML. Leave that outside of your PHP. <?php echo "<p>Hello World</p>"; // Alway wrong. ?> <p>Hello World</p> <!-- Does the same thing, faster, and is more readable. --> Escaping to PHP is a waste if all you are going to do is pass in static text or static ...


34

You don't have to learn JavaScript and HTML to create web applications. But you will. If you really want to write webapps in mostly Java, have a look at the Google Web Toolkit, which does vast amounts of Java to JS, and can satisfy a good chunk of the code needed for a webapp. Django is a similar framework for Python. And if you really want to avoid ...


33

There is no way to avoid that. They are coupled because they interact with each other. If your javascript intends on doing any kind of DOM manipulation, then it needs a way to reference the DOM. There are various conventions for it. The Level 2 DOM API provides the getElementById, getElementByTagName, and getElementsByName methods. To this day these are ...


33

The true story is that b and i were first obsoleted, deprecated, cursed, and anatematized as “presentational” in various HTML5 drafts (broadly speaking), but then they realized that these tags are widely used and also generated by many authoring programs. Instead of simply allowing them, they developed contrived new “semantic” definitions for them, to be ...


31

I have used this technique exclusively for a web application we're working on. My backend is hosted on Google App Engine using the Java SDK, and my frontend uses HTML, CSS, and JavaScript (with jQuery). The project is a smaller one with just myself and a Web designer, and we both feel that this method has helped us work a lot faster and get something to ...


31

Because making best guesses is the right thing to do, from a browser-maker's perspective. Consider the situation: ideally, the HTML you receive is completely correct and to spec. That's great. But the interesting part is what happens when the HTML is not correct; since we're dealing with input from a source that we have no influence on, really, we have to be ...


30

Adobe already did it with Adobe Air, and Mozilla too with Prism . Google also tried to bridge the gap between desktop and web with Google Gears. But in general, web technologies are not suited for many types of desktop applications, here some reasons why: No immediately available full hardware access. No low level system access. No easily available ...


30

Not anytime soon. The era of WYSIWYG editors is long over (like the dinosaurs) but companies continue to pump it out. I remember the days of using Dreamweaver and having dozens of spacer.gif images to put the layout in the same way. Software like this is fool's gold - it's meant to appeal to people who want something quick and dirty (tomorrow as opposed ...


30

I have said this before and will say it again "working code is more valuable than pretty code". If you change code the chances are high that you will change its behavior, if this is tested code then you have just invalidated all the testing effort, and will need to repeat the tests. By all means encourage your juniors to write clean understandable code, ...


28

Today, in our work as in our life, it is more important know how to find information rather than know the information itself. I mean that a good developer is a person able to find documentation, network, and that share with an open mind. I am an experienced .NET developer and, believe me, for every project I work on I have to learn new things about the ...


28

Former Designer here, turned Dev, and I used to piss and moan about Web Controls too. Honestly, its MUCH cheaper for a designer to adjust their practices than for a .NET Developer to delve into a custom impelmentation of a GridView because the designer INSISTED that each TD have a 'rel' tag (or whatever). As MainMa very wisely pointed out, the decision to ...


27

I think the problem is that you are comparing cleanly written server side templating to badly written ad-hoc client side HTML generation. Of course the cleanly written code is easier to read, maintain, and trace. You call the client side code "mounds of HTML", but of course it's the same HTML wherever it's generated. The "mound" is really the big lump ...


27

The reason is simple: At the time of the first graphical browsers, NCSA Mosiac and later Netscape Navigator, almost all HTML was written by hand. The browser authors (Netscape was built by ex-Mosaic folks) recognized quickly that refusing to render incorrect HTML would be held against them by the users, and voila!



Only top voted, non community-wiki answers of a minimum length are eligible