What styles do I need to add to my heading classes to make any element behave like heading tags…
.h1, .h2, .h3, .h4, .h5, .h6 {
// make akin to h tags
}
I might be using them on div
or span
or li
etc… so need a fairly robust reset. I am thinking things like display: block;
but don’t really know what the definitive set of required rules are.
Edit: clarification
Although already answered for me – I thought I would clarify my use case as I seem not to have articulated it well.
I need to change some h1
, h2
etc… tags into div
or span
or li
tags on a large site where I don’t control all of the HTML. I want the new tag, whatever it may be, to behave exactly like it did when it was a heading tag. It must work cross browser, and I was hoping for a definitive, one rule fits all solution that is easy to maintain and has no significant pitfalls (in terms of SEO and accessibility etc…).
3
Answers
Well the standard CSS rules are different per browser.
More information in this answer:
Browsers' default CSS for HTML elements
As Bert Vermeire stated it’s different for each browser.
That’s why it’s better to create some reboot/reset css file which contains the
span.h1
to h6,p.h1
to h6, … (as for divs, not sure how you intended to use that) which cancels all margins, paddings, line-heights, font-weights, and so on.Here is a sample of one of my projects:
Be careful though, as
rem
sizes aren’t supported on every browser. Useem
,px
, … insteadThe properties can be: