Quote:
Originally Posted by paperwhite13
Wouldn’t it be semantically correct?
Code:
h1 {
/* elided */
}
|
My personal take is that I never directly style a bare element. I create a class selector and apply the attributes to that, then apply the style to the element (h1 in this case).
I do this because
h1 has semantic meaning, and so all headings at the same level should use that element. But, many books want "special" chapters (like "Acknowledgements" or "Epilogue") to look slightly different from "normal" chapters. For example, some books use a fairly large (3em to 4em) font for chapters that are just a bare number (i.e., 7), while the "Epilogue" is only 1.5 to 2em. Those "special" chapters are still at the same level as the "normal" ones...they aren't parents or children...so they need the same element.
By directly styling the
h1, you have to "undo" the base formatting for the "special" chapters. You would then use something like
h1.normalchapter and
h1.specialchapter. But, if you are going to do that, why bother restricting to
h1? If you decide you need to change the level of headings down or up, then the stylesheet has to be changed to match. Without restricting to a single element
and a class, instead only using a class, it's more flexible.