June 1, 201115 yr Was wondering what the best practice is, with regards to how to treat simple things like dates? Would wrapping them in span or em tag pairs be the most recommended thing to do? I normally have the dates placed underneath a heading. Is it necessary to also add it into a div just for the sake of positioning, or can I really just use a span or em tag to settle it. Edited June 1, 201115 yr by jesuis_danny
June 1, 201115 yr I'd advise against using a div in situations like this, in general it's best to avoid using too many divs on a page, as a date is still just standard copy you should use a p tag <p></p> Any copy on a page should really be contained with a p tag unless it's a list item (<li>).
June 1, 201115 yr HTML5 time tag, http://html5doctor.com/the-time-element/ If however you are not sporting HTML5 then i would personally wrap it in a div called meta but it's a matter of preference.
June 1, 201115 yr Author Any copy on a page should really be contained with a p tag unless it's a list item (<li>). Thanks for the tip Alex. Can anybody confirm Alex's statement? I was always under the impression that p tags should only be used naturally, for paragraphs. Edited June 1, 201115 yr by jesuis_danny
June 1, 201115 yr Any copy on a page should really be contained with a p tag unless it's a list item (<li>). I agree with jesuis_danny. This is debatable IMHO. Just the date on it's own wouldn't be a paragraph. If it's within another paragraph, I'd personally use a span within a <p> : <p>This is a paragraph with the <span id='mydate'>Date goes here</span> within it</p> If it's just the date floating about on it's own, then perhaps a <span> might be a better answer, as it is not a paragraph.
June 1, 201115 yr Apologies I haven't explained that nearly as well as I'd of hoped (lack of sleep I'm afraid), the p tag should be used to define paragraphs yes but what I meant was that there shouldn't be any copy sitting outside a p tag if it isn't in an li tag, for example: <p>This is a paragraph</p> This is another paragraph Personally I'd use a p tag for the date but it's really each to their own, whatever your more comfortable doing should be the method of choice (providing it's valid).
June 1, 201115 yr HTML5 time tag, http://html5doctor.com/the-time-element/ If however you are not sporting HTML5 then i would personally wrap it in a div called meta but it's a matter of preference. As above, we should really be coding for html5 now.... <time>26/7/2011</time>
June 1, 201115 yr As above, we should really be coding for html5 now.... <time>26/7/2011</time> Of course. That probably provokes the requirement of people to include xhtml or html5 in their question, as a lot of the time there will now be two answers.
June 1, 201115 yr Of course. That probably provokes the requirement of people to include xhtml or html5 in their question, as a lot of the time there will now be two answers. I don't think professional designers/developers should be using XHTML anymore; HTML5 (at least the basic markup) is fully-supported with the HTML5Shiv in place. HTMl5 gives you a lot of great options to keep your markup semantic and it makes styling MUCH easier since you don't have to give IDs to divs, you can just use an element name instead. So yeah, go HTML5.
June 2, 201115 yr HTML5 (at least the basic markup) is fully-supported with the HTML5Shiv in place. I wasn't aware of that, +1 for the heads up, again, Porky!
June 2, 201115 yr Gotta agree with above in that <time> would be the most current mark-up to go with. Although you can only mark up precise dates within the Gregorian calendar but unless you're running a museum, i can't see this being a problem.
Create an account or sign in to comment