March 30, 2012

Is it correct to use DIV inside FORM?

Question by demas

I’m just wondering what are you thinking about DIV-tag inside FORM-tag?

I need something like this:

<form>
  <input type="text"/>
  <div> some </div>
  <div> another </div>
  <input type="text" />
</form>

Is it general practice to use DIV inside FORM or I need something different?

Answer by Starx

No, its not

<div> tags are always abused to create a web layout. Its symbolic purpose is to divide a section/portion in the page so that separate style can be added or applied to it. [w3schools Doc] [W3C]

It highly depends on what your some and another has.

HTML5, has more logical meaning tags, instead of having plain layout tags. The section, header, nav, aside everything have their own semantic meaning to it. And are used against <div>

March 28, 2012

When is it semantically correct to use the hr element?

Question by John Doe

The HTML5 reference says that

The hr element represents a paragraph-level thematic break, e.g. a scene change in a story, or a transition to another topic within a section of a reference book.

That description is not enough descriptive to me. I use the hr element in my HTML documents as a way to separate content. Is this correct?

Could anyone give a few examples on when to use it (apart from the examples shown) and when to use CSS styling instead?

Answer by ceoux

It’s proper to use it when you have, say, several paragraphs with two distinct themes.

<p>Paragraph about domestic kittens</p>
<p>Paragraph about kittens' favourite foods</p>
<p>Paragraph about kittens' playfulness</p>
<hr>
<p>Paragraph about my day at work</p>

If you’d like to otherwise separate themes among images and content, I believe this is also appropriate.

<img src="/img/kitten.jpg" alt="kitten playing with ball">
<img src="/img/kitten1.jpg" alt="kitten drinking milk">
<hr>
<img src="/img/zebra.jpg" alt="zebras in the wild">

The new use of hr seems to just be for distinguishing topics within HTML. If you find that your content is well-connected, don’t feel that you need to use the tag.

Answer by Starx

According to this article

In HTML 4.01, the <hr> tag represented a horizontal rule.

In HTML5, the <hr> tag defines a thematic break.

However, the <hr> tag may still be displayed as a horizontal rule in
visual browsers, but is now defined in semantic terms, rather than
presentational terms.

All layout attributes (align, noshade, size, and width) in HTML 4.01
was deprecated in HTML 4.01, and is not supported in HTML5. Use CSS to
style the <hr> element instead.

In HTML5, use <hr> when you are diverting your topic from the previously written paragraph.

...

Please fill the form - I will response as fast as I can!