The difference between a div and a span

Monday July 31, 2006 @ 01:12 PM (PDT)

I've interviewed what seems like an endless stream of web designers (emphasis on designers) over the last month or two, and they all seem to have one thing in common: they don't know what the hell they're talking about.

One of the technical questions I always ask and nobody ever answers correctly is, "What is the difference between a div and a span?"

Invariably, each candidate launches into a nervous, stuttering, uncertain description of how they use divs for certain things and spans for other things. When I ask why they use them for different things, the answer is always something along the lines of, "Um...I don't really know."

I had no idea that the level of basic HTML knowledge among people calling themselves web designers (and especially those calling themselves web developers, which is the position we're interviewing for) is so low. This is absolutely shocking to me. Some of the people I've interviewed have done very high-profile websites and have excellent design skills. The fact that they claim to know HTML without understanding this fundamental concept is surprising, absurd, and above all frustrating.

The difference between a div and a span is very simple. The HTML 4 specification has this to say on the subject (emphasis added):

The DIV and SPAN elements, in conjunction with the id and class attributes, offer a generic mechanism for adding structure to documents. These elements define content to be inline (SPAN) or block-level (DIV) but impose no other presentational idioms on the content. Thus, authors may use these elements in conjunction with style sheets, the lang attribute, etc., to tailor HTML to their own needs and tastes.
http://www.w3.org/TR/html401/struct/global.html#h-7.5.4

That's it. That's the answer. All I'm looking for are the words "inline" and "block-level". If you say those words in the correct order, you pass the test. A++++++, would hire again.

Of course, this is only one of the five or so technical questions that every candidate gets horribly wrong. Next time I'll write about the differences between absolute, relative, fixed, and static positioning in CSS.

Update: About an hour after posting this I interviewed another candidate over the phone and he aced all my questions. First time that's ever happened. I should have blogged about this sooner.

Comments

he probably had w3.org and google on the other end of the phone.

Gravatar icon
someguy
Tuesday August 01, 2006 @ 01:52 AM (PDT)

Nothing wrong with that.

Gravatar icon
Tuesday August 01, 2006 @ 09:11 AM (PDT)

Dang it, I could have passed that test! Still, it's more important they know the difference between an id and a class, hehe.

Gravatar icon
NC
Friday August 04, 2006 @ 03:53 PM (PDT)

After I read this post a week ago I thought about inquiring for a position. I've been doing the self-employed thing for a while, and I just started up some low maintenance ventures. Having a real paid job would be nice, and I'd probably want to move closer to the area. I don't have a resume prepared, but I think I could pass your test.

Gravatar icon
Thursday August 10, 2006 @ 02:54 AM (PDT)

I want to ask the author if he knows everything 100% in his speciality.

Gravatar icon
author
Thursday November 20, 2008 @ 10:39 AM (PST)

Not everyone who have used HTML should know about the “difference” between DIV and SPAN.There is ABSOLUTELY nothing wrong in not knowing something.Mr.whoeverwrotethis ,are you perfect in everything that you know.You,know how frustrating interviewers of your kind are.Try to allow leverage to the candidates,YOU ARE NO EINSTEIN.

Gravatar icon
author
Thursday November 20, 2008 @ 10:44 AM (PST)

I agree everyone cannot know everything.. but there are certain basic stuff that everyone gotta know.. In web design, you often deal with DIV, SPAN tags almost everyday (especially when you are using external JS libraries to dynamically modify the content).. so, if people never know this, fire them.. that’s the right thing to do for at least 80% of the time.

Gravatar icon
karthik
Friday February 20, 2009 @ 01:01 PM (PST)

Anybody can quick reference the w3 and spit out that div = block, span = inline, but whether you know what “inline” and “block” mean is the more important question. But it is unwise to disqualify a candidate on this trivial fact alone, for something that can be picked up on in a matter of a couple of minutes.

Gravatar icon
skeenote
Friday October 30, 2009 @ 12:53 PM (PDT)
New comment

required, won't be displayed

optional

Don't type anything here unless you're an evil robot:


And especially don't type anything here:

Basic XHTML (including links) is allowed, just don't try anything fishy. Your comment will be auto-formatted unless you use your own <p> tags for formatting. You're also welcome to use Textile.

Copyright © 2002-2010 Ryan Grove. All rights reserved.
Powered by Thoth.