{"id":14110,"date":"2011-09-06T18:43:28","date_gmt":"2011-09-07T01:43:28","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14110"},"modified":"2017-12-22T09:02:59","modified_gmt":"2017-12-22T16:02:59","slug":"text-align","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/t\/text-align\/","title":{"rendered":"text-align"},"content":{"rendered":"
The These are the traditional values for text-align:<\/p>\n “Content” is used here as as term instead of “text”, because while text-align certainly affects text, it affects all inline or inline-block elements in that container. <\/p>\n There are two new values in CSS3 as well, start and end. These values make multiple language support easier For example, English is a left-to-right (ltr) language and Arabic is a right-to-left (rtl) language. Using “right” and “left” for values is too rigid and doesn’t adapt as the direction<\/a> changes. These new values do adapt:<\/p>\n There is also There are a few things in the spec that don’t have any browser support yet. One is the value “start end” which would align the first line as if was “start” and any subsequent lines as if it was “end”. Another is giving the value a string, like This text is left aligned.<\/p>\n This text is right aligned.<\/p>\n I’m centered!<\/p>\n I’m justified. I fill the space exactly (except on the last line), even if I have to stretch a bit at times.<\/p>\n I inherit the alignment of my parent. In this case, that means left.<\/p>\n For left, right, center, justify:<\/p>\n For the The text-align property in CSS is used for aligning the inner content of a block element. p { text-align: center; } These are the traditional values for text-align: left – The default value. Content aligns along the left side. right – Content aligns along the right side. center – Content centers between the left and […]<\/p>\n","protected":false},"author":1036,"featured_media":0,"parent":13949,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-almanac-single.php","meta":{"_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":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":196786,"url":"https:\/\/css-tricks.com\/almanac\/properties\/t\/text-align-last\/","url_meta":{"origin":14110,"position":0},"title":"text-align-last","date":"February 26, 2015","format":false,"excerpt":"text-align-last lets you control the alignment of the last (or only) line of text right before a forced line break \u2014 for example the end of a paragraph or the line right before a tag. .intro-graph { text-align-last: center; } At the time of this writing, only Mozilla browsers and\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":335691,"url":"https:\/\/css-tricks.com\/almanac\/properties\/p\/place-self\/","url_meta":{"origin":14110,"position":1},"title":"place-self","date":"March 2, 2021","format":false,"excerpt":"The place-self property in CSS is shorthand for the align-self and justify-self properties, combining them into a single declaration in CSS Grid and Flexbox layouts, where align-self and justify-self (CSS Grid only) are values that align an individual item in the block and inline directions. .element { place-self: center start;\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":340540,"url":"https:\/\/css-tricks.com\/almanac\/properties\/p\/place-content\/","url_meta":{"origin":14110,"position":2},"title":"place-content","date":"May 13, 2021","format":false,"excerpt":"The place-content property in CSS is shorthand for the align-content and justify-content properties, combining them into a single declaration in CSS Grid and Flexbox layouts, where align-content and justify-content are values that align an individual item in the block and inline directions. .element { display: flex; place-content: start space-evenly; }\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14132,"url":"https:\/\/css-tricks.com\/almanac\/properties\/v\/vertical-align\/","url_meta":{"origin":14110,"position":3},"title":"vertical-align","date":"September 6, 2011","format":false,"excerpt":"The vertical-align property in CSS controls how elements set next to each other on a line are lined up. img { vertical-align: middle; } In order for this to work, the elements need to be set along a baseline. As in, inline (e.g. , ) or inline-block (e.g. as set\u2026","rel":"","context":"In \"vertical-align\"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":343682,"url":"https:\/\/css-tricks.com\/snippets\/css\/complete-guide-grid\/","url_meta":{"origin":14110,"position":4},"title":"A Complete Guide to CSS Grid","date":"May 12, 2021","format":false,"excerpt":"Our comprehensive guide to CSS grid, focusing on all the settings both for the grid parent container and the grid child elements.","rel":"","context":"In \"grid\"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2018\/12\/grid-guide.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":336695,"url":"https:\/\/css-tricks.com\/almanac\/properties\/j\/justify-self\/","url_meta":{"origin":14110,"position":5},"title":"justify-self","date":"March 18, 2021","format":false,"excerpt":"The justify-self property in CSS sets the justification of an element within its containing block. Its behavior depends on the display of the containing block. For example, if the containing block is a grid container (i.e. display: grid), we can justify the element in it along the \"inline\" axis (which,\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2019\/12\/css-tricks-logo-gradient-outline.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14110"}],"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=14110"}],"version-history":[{"count":11,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14110\/revisions"}],"predecessor-version":[{"id":264333,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14110\/revisions\/264333"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/13949"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=14110"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=14110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}text-align<\/code> property in CSS is used for aligning the inner content of a block element.<\/p>\n
p {\r\n text-align: center;\r\n}<\/code><\/pre>\n
\n
left<\/code> – The default value. Content aligns along the left side.<\/li>\n
right<\/code> – Content aligns along the right side.<\/li>\n
center<\/code> – Content centers between the left and right edges. White space on the left and right sides of each line should be equal.<\/li>\n
justify<\/code> – Content spaces out such that as many blocks fit onto one line as possible and the first word on that line is along the left edge and the last word is along the right edge.<\/code>\n<\/li>\n
inherit<\/code> – The value will be whatever the parent element’s is.<\/li>\n<\/ul>\n
\n
start<\/code> – Same as “left” in ltr, same as “right” in rtl.<\/li>\n
end<\/code> – Same as “right” in ltr, same as “left” in rtl.<\/li>\n<\/ul>\n
match-parent<\/code>, which is similar to
inherit<\/code>, only that the new value is calculated against the current element’s direction instead of, you know, not doing that. <\/p>\n
text-align: \".\" start;<\/code> The text will aline along the first occurrence of that <string>, as in to line up a column of numbers along a decimal point.<\/p>\n
Examples<\/h3>\n
Other Resources<\/h3>\n
\n
Related Properties<\/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 3.5+<\/td>\n 3+<\/td>\n Any<\/td>\n Any<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n start<\/code> and
end<\/code> values:<\/p>\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 3.1+<\/td>\n 3.6+<\/td>\n None<\/td>\n None<\/td>\n Any<\/td>\n Any<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"