Skip to content
Home » Development » Centering an equation as part of a paragraph

Centering an equation as part of a paragraph

Abstract

Dr. John Stockton wanted to write paragraphs in HTML that contained one or more centred equations. It had to be acceptable to validators and testers, and work in IE4.

Example

This is a paragraph of waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle here comes an equation: A = B + C and the waffles continues waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle waffle until the end.

Code

(X)HTML

<p>&hellip;<span class="equation">A = B + C</span>&hellip;</p>

CSS

span.equation {
  display: block;
  text-align: center;
}

Conclusion

Well it validates; as for working in IE4, then it should, as both display and text-align are both supported. However, practically it apparently doesn’t. More investigation needed.

Post a Comment

Your email is never published nor shared. Required fields are marked *