Vertically Aligning Inline Images Inside of a Paragraph

Published December 14, 2012 | Categories: Cascade CMS
By default any inline image will align with the baseline of the paragraph, unless a “margin-bottom” is applied to the paragraph’s baseline.
There are six lines that can be used for vertical alignment:
- Top line is the line above all of the content.
- Text-top line is top of the text that also includes any accent marks.
- Middle line is the middle of the letter x-height.
- Baseline is where all letters sit.
- Text-bottom line is the bottom of all text that includes descenders.
- Bottom line is below all content.
Given the above information, you can then determine how you want to change the vertical position of images in its surrounding text using the CSS “vertical-align” property. These properties can include, top, text-top, middle, baseline, text-bottom, bottom, sub, super, percentage and length.
Below are examples of each:
- Top: img.class-name {vertical-align:top;}
- Text-top: img.class-name {vertical-align:text-top;}
- Middle: img.class-name {vertical-align:middle;}
- Baseline: img.class-name {vertical-align:baseline;}
- Text-bottom: img.class-name {vertical-align:text-bottom;}
- Bottom: img.class-name {vertical-align:bottom;}
- Sub: (aligns with the baseline position of subscript content) img.class-name {vertical-align:sub;}
- Super: (aligns with the baseline position of superscript content) img.class-name {vertical-align:super;}
- Percentage: (0% is baseline, by raising or lowering the value it can go above or below the baseline), example 1: img.class-name {vertical-align:5%;}, example 2: img.class-name {vertical-align:-5%;}
- Length: (0px is baseline, by raising or lowering the value it can go above or below the baseline), example 1: img.class-name {vertical-align:5px;}, example 2: img.class-name {vertical-align:-5px;}
The above information was gathered from maxdesign.
Recent Posts



