space before heading larger than space after heading with HTML and CSS -
in renderings of html code like
<p>paragraph 1.</p> <h3>heading</h3> <p>paragraph 2.</p> i have more vertical space before heading after heading. reason: heading should semantically belong more second paragraph first one. of course, both space values should exceed usual interline-spacing. exact amount of space , way render (if client decides render vertical space @ all) should left client (browser, braille device, printer, speech engine ...) create pleasant output.
my best try far machine is
<p style="margin-bottom:3ex">paragraph 1.</p> <h3>heading</h3> <p>paragraph 2.</p> however, i'm feeling uncomfortable in hardcoding exact value might similar setups machine, not universally. better suggestions html , css? (if possible, don't use more stuff html , css: i'd page intelligible many clients possible.)
in essence, wish have html+css solution effect on spacing before/after heading same of following pseudocode:
if(vertical_space_before <= vertical_space_after) { mean_vertical_space := (vertical_space_before + vertical_space_after)/2; vertical_space_before := 1.1*mean_vertical_space; vertical_space_after := 0.9*mean_vertical_space; }
https://jsfiddle.net/kqun2wbo/2/
css:
p { margin-bottom: 25px; } h3 { margin-bottom: 10px; } html:
<p>paragraph 1.</p> <h3>heading</h3> <p>paragraph 2.</p>
Comments
Post a Comment