{"id":14132,"date":"2011-09-06T18:59:38","date_gmt":"2011-09-07T01:59:38","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14132"},"modified":"2020-02-29T06:47:16","modified_gmt":"2020-02-29T13:47:16","slug":"vertical-align","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/v\/vertical-align\/","title":{"rendered":"vertical-align"},"content":{"rendered":"
The In order for this to work, the elements need to be set along a baseline. As in, The valid values are:<\/p>\n You can see examples<\/a> of each here:<\/p>\n A common use case is lining up an avatar with a username. To get them centered along a line, you’d use Each element lines up according to the line you’ve set, which doesn’t change from element to element. So, you can mix-and-match which elements have which value – the elements don’t affect each other.<\/p>\n Note that vertical-align is useful on table-cell elements as well,<\/strong> aligning the content within them. Sticking to top, middle, and bottom is the best bet though, as the other values have inconsistent cross-browser results.<\/p>\n Note that some replace elements (e.g. The vertical-align property in CSS controls how elements set next to each other on a line are lined up. img […]<\/p>\n","protected":false},"author":1036,"featured_media":0,"parent":13953,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-almanac-single.php","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","_share_on_mastodon":"0","_share_on_mastodon_status":"%title% %permalink%"},"tags":[1152],"acf":[],"share_on_mastodon":{"url":"","error":""},"jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14132"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/1036"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=14132"}],"version-history":[{"count":9,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14132\/revisions"}],"predecessor-version":[{"id":254648,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14132\/revisions\/254648"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/13953"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=14132"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=14132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}vertical-align<\/code> property in CSS controls how elements set next to each other on a line are lined up. <\/p>\n
img {\r\n vertical-align: middle;\r\n}<\/code><\/pre>\n
inline<\/code> (e.g.
<span><\/code>,
<img><\/code>) or
inline-block<\/code> (e.g. as set by the
display<\/code><\/a> property) elements. <\/p>\n
\n
baseline<\/code> – This is the default value.<\/li>\n
top<\/code> – Align the top of the element and its descendants with the top of the entire line.<\/li>\n
bottom<\/code> – Align the bottom of the element and its descendants with the bottom of the entire line.<\/li>\n
middle<\/code> – Aligns the middle of the element with the middle of lowercase letters in the parent.<\/li>\n
text-top<\/code> – Aligns the top of the element with the top of the parent element’s font<\/li>\n
text-bottom<\/code> – Aligns the bottom of the element with the bottom of the parent element’s font.<\/li>\n
sub<\/code> – Aligns the baseline of the element with the subscript-baseline of its parent. Like where a
<sub><\/code> would sit.<\/li>\n
super<\/code> – Aligns the baseline of the element with the superscript-baseline of its parent. Like where a
<sup><\/code> would sit.<\/li>\n
length<\/code> – Aligns the baseline of the element at the given length above the baseline of its parent. (e.g. px, %, em, rem, etc.)<\/li>\n<\/ul>\n
<\/code>Check out this Pen!<\/a><\/pre>\n
vertical-align: middle;<\/code>. Although note that it centers the text according to its tallest ascender and deepest descender.<\/p>\n
<\/figure>\n
<\/figure>\n
More Information<\/h3>\n
\n
Browser Support<\/h3>\n
\n\n
\n Chrome<\/span><\/th>\n Safari<\/span><\/th>\n Firefox<\/span><\/th>\n Opera<\/span><\/th>\n IE<\/span><\/th>\n Android<\/span><\/th>\n iOS<\/span><\/th>\n<\/tr>\n<\/thead>\n\n \n Any<\/td>\n Any<\/td>\n Any<\/td>\n 4+<\/td>\n 4+<\/td>\n Any<\/td>\n Any<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <textarea><\/code>) are inline, but their baseline isn’t specified, so behavior may vary from browser to browser.<\/p>\n","protected":false},"excerpt":{"rendered":"