I just found a page of web developer interview questions, and I’m not sure what the answers are for two of them. For Q1, I pick answer e. For Q2, I pick answer b, but I’m not sure if there are better ways to do it.
-
Which markup structure is most semantic for a title within a document body, considering that the title may be horizontally centered using a large, bold, red font?
a.
<h1>This is a Title</h1>b.
<p align="center"><font size="+3"><b>This is a Title</b></font></p>c.
<h1 style="font-weight:bold; font-size:large; text-align:center; color:red;">This is a Title</h1>d.
<title>This is a Title</title>e.
<h1 class="LargeRedBoldCenterHeading">This is a Title</h1>f.
<span class="title">This is a Title</span> -
Are each of the following footer markup solutions acceptable? Why or why not? What alternate solution(s) would you propose?
a.
<div id="footer">
Copyright 2010 My Company | This text is arbitratry.
</div>b.
<div id="footer">
<p>Copyright 2010 My Company | This text is arbitratry.</p>
</div>
The correct answer for
1.isaas you should only have oneh1tag on your page (so a class is probably unnecessary if it’s only for theh1) and because the class used ineis not semantic (e.g. “Title”) but instead describes a very particular styling so would be useless if you later changed the way you want to display the title.In fact you can rule out the other options like this:
b) Uses
alignattribute, uses afonttag, uses abtag (this one is iffy but they would prefer you usedem), uses aptag for a heading.c) Uses inline styles
d) Uses the
titleelement in thebodyto try and render content. This belongs in theheadand shouldn’t display anything on the page anyway even if it was incorrectly and invalidly placed in thebody.e) Uses a class which is poorly named. Classes should describe the meaning of the class (e.g. “EmphasisedHeader”, “HelpButton” etc. ) and not how the class is rendered. Think of them as a tag – would you like a
<LargeRedBoldCenterHeading>tag or an<EmphasisedHeader>tag?f) Invalid HTML
For question
2.the answer is trickier. Theptag is unnecessary as adivis already a block element by default.In HTML 5 there is a
footerelement for this, and indeed one of the more attractive but abandoned proposals early on was to allow you to name any element you like (perhaps using your own “meta-doctype”) and just have them render like adiv(e.g. you could have an<adbox>tag instead of<div class="adbox">).It could probably be argued that they should be in a
<ul id="footer">with each element in a<li>, but attempting to style that with a|divider would be painful to do in a compliant and cross-browser fashion.I would be happy with
a.