Home > Article > Web Front-end > Why is Inline-Block Display Not Working in Internet Explorer 8?
Despite documentation indicating support for inline-block, it may fail to render correctly in Internet Explorer 8. This issue often manifests when attempting to horizontally align elements.
To resolve this, consider the following:
Start your HTML document with the following doctype declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This will ensure that IE8 adheres to the correct rendering specifications.
Consider the following CSS and HTML code:
<code class="css">span, ul, ul li { display: inline-block; vertical-align: top; margin: 0; padding: 0; list-style: none; } </code>
<code class="html"><span>i would want</span> <ul> <li>this</li> <li>on</li> <li>one line.</li> </ul></code>
With the doctype declaration in place, this code should render inline in IE8 as expected.
Adding the correct doctype declaration is essential for resolving inline-block rendering issues in Internet Explorer 8. This simple adjustment ensures that the browser interprets and applies CSS styles as intended.
The above is the detailed content of Why is Inline-Block Display Not Working in Internet Explorer 8?. For more information, please follow other related articles on the PHP Chinese website!