html - Does W3C allow <h#> elements to be display:inline;? -
doing code review, noticed heading using <span>
tags instead of headings, suggested using <h4>
tag, gain semantic benefits. context website footer, there various lists of links under different headings.
<span>category 1 links</span> <ul> <li>link 1 in footer</li> <li>link 2 in footer</li> <li>link 3 in footer</li> <li>link 4 in footer</li> <li>link 5 in footer</li> </ul>
the counterargument <h4>
"block-level" element, whereas inline element needed. therefore didn't think element should changed. (and yes, knows css , familiar display: inline;
property.)
that sounds absolutely insane me--goes against thought best practice: separation of content , presentation, semantic web, purposes of html , css... yet in trying formulate response, came across this section in html 4.01 spec:
certain html elements may appear in body said "block-level" while others "inline" (also known "text level").
...
style sheets provide means specify rendering of arbitrary elements, including whether element rendered block or inline. in cases, such inline style list elements, may appropriate, speaking, authors discouraged overriding conventional interpretation of html elements in way.
the alteration of traditional presentation idioms block level , inline elements has impact on bidirectional text algorithm. see section on effect of style sheets on bidirectionality more information.
so here question: section make issue sufficiently vague there valid difference of opinion here, or (as had thought) pretty clear in 1 way or other? if section open interpretation, there other w3c guidelines more concrete?
i don't want opinions on this, want make sure i'm understanding spec , w3c guidelines correctly: there true ambiguity here, or not?
first of all, quoted section indeed 14-year old html 4.01 specification. not remember ever reading of type in html5 specs. think deemed remark @ time has since been obsoleted experience. don't forget html4 1 separate html , css, , such contains 'mistakes' quoted remark later 'corrected'.
in essence, there should not implicitly locked relationship between semantic markup , styling. hx
elements, div
block level element, because of way interacts other elements, elements can contain - inline element must not contain block element while block element can contain both inline , block elements, bar explicitly defined relationships such ul > li
, table > tr > td
. separation of semantics , presentation should kept strict specifications of markup language html should never mention existence of concept of stylesheets - stylesheets can applied anything, not html, , html feeds many more technologies browsers.
from web developer's perspective, absolutely right. block nature of h4
element merely implies relationship potential child elements, , default representation in browser's default stylesheet. css developer wants stylesheet own choice - care applies display:table-cell
rule if fits design.
tl;dr: there no ambiguity, , should write css conform how want display html, not adapt html requirements of css. using span
h4
required plain wrong semantic (and seo) perspective.
Comments
Post a Comment