CSS vertical-align Property Last Updated : 24 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The CSS vertical-align property is used to control the vertical positioning of inline elements or table cells. It helps in aligning images or text within the same line and is commonly used to adjust content in table cells. This property is perfect for aligning elements relative to each other without affecting the entire layout.Syntaxvertical-align: baseline | length | sub | super | top | text-top | middle | bottom | text-bottom | initial | inherit;Note: The vertical-align property is primarily used to align inline elements (like images) with text.It can also be used for aligning content within table cells.Block-level elements (e.g., div, p, h1, ul, ol) cannot be aligned using vertical-align.Property ValuesValueDescriptionbaselineAligns the element’s baseline with the baseline of its parent. This is the default value and may vary by browser.subPositions the element’s baseline as a subscript relative to its parent’s baseline.superPositions the element’s baseline as a superscript relative to its parent’s baseline.text-topAligns the top of the element with the top of the parent's font.text-bottomAligns the bottom of the element with the bottom of the parent's font.middleCenters the element's vertical midpoint with the parent's vertical midpoint.topAligns the element’s top with the top of the tallest element in the same line.bottomAligns the element’s bottom with the bottom of the shortest element in the same line.lengthMoves the element’s baseline by a specified length above (or below for negative values) the parent’s baseline.percentageShifts the element’s baseline by a percentage relative to the parent’s baseline, based on the line-height property.initialResets the alignment to the default value (baseline).inheritAdopts the vertical alignment value from the parent element.Let's understand this property through this exampleExample: This example explains all the values of vertical-align property. HTML <!DOCTYPE html> <html> <head> <title> CSS vertical-align Property </title> <style> .img1 { vertical-align: baseline; } .img2 { vertical-align: sub; } .img3 { vertical-align: super; } .img4 { vertical-align: text-top; } .img5 { vertical-align: text-bottom; } .img6 { vertical-align: middle; } .img7 { vertical-align: top; } .img8 { vertical-align: bottom; } .img9 { vertical-align: 25px; } img.img10 { vertical-align: 100%; } .img11 { vertical-align: baseline; } .img12 { vertical-align: inherit; } </style> </head> <body> <h2>vertical-align: baseline</h2> <p> <img class = "img1" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: sub</h2> <p> <img class = "img2" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: super</h2> <p> <img class = "img3" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: text-top</h2> <p> <img class = "img4" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: text-bottom</h2> <p> <img class = "img5" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: middle</h2> <p> <img class = "img6" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: top</h2> <p> <img class = "img7" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: bottom</h2> <p> <img class = "img8" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: length</h2> <p> <img class = "img9" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: percentage</h2> <p> <img class = "img10" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: initial</h2> <p> <img class = "img11" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p><br> <h2>vertical-align: inherit</h2> <p> <img class = "img12" src = "https://media.geeksforgeeks.org/wp-content/uploads/gfgc.png" alt = "" class="alignnone size-medium wp-image-862984" /> A computer science portal </p> </body> </html> Output:Supported Browsers The browser supported by vertical-align property are listed below:Chrome 1.0Edge 12.0Firefox 1.0Internet Explorer 4Safari 1.0Opera 4.0 Comment More infoAdvertise with us D DannanaManoj Follow Improve Article Tags : Web Technologies CSS CSS-Properties Similar Reads CSS @charset Rule The @charset rule specifies the character encoding used in the style sheet. The @charset must be the first element in the style sheet and if several @charset rules are defined then the only first one is used. It can not be used in the <style> element where the character set of the HTML page is 3 min read CSS @keyframes Rule The CSS @keyframes rule defines animations by specifying keyframes that describe the styles to be applied at various points during the animation duration. It allows for smooth transitions and transformations in web elements, controlled through percentages or from-to values.Note:For optimal browser s 3 min read CSS @media Rule The @media CSS at-rule is used to apply a different set of styles for different media/devices using the Media Queries. A Media Query is mainly used to check the height, width, resolution, and orientation(Portrait/Landscape) of the device. This CSS rule is a way out for making more out of responsive 5 min read CSS align-content property The align-content property changes the behavior of the flex-wrap property. It aligns flex lines. It is used to specify the alignment between the lines inside a flexible container. This property defines how each flex line is aligned within a flexbox and is only applicable if flex-wrap: wrap is applie 4 min read CSS align-items Property The align-items property in CSS is used to align flex items along the cross-axis within a flex container. It accepts values like flex-start, flex-end, center, baseline, and stretch, controlling the vertical alignment of items in a flexbox.Syntaxalign-items: normal | stretch | center | flex-start | f 7 min read CSS align-self Property The align-self property in CSS is used to align the selected items in the flexible container in many different manners such as flex-end, center, flex-start, etc. Syntax:align-self: auto|normal|self-start|self-end|stretch|center |baseline, first baseline, last baseline|flex-start |flex-end|baseline|s 5 min read CSS all Property The all property in CSS is the shorthand property used to set all the element's values to their initial or inherited values or in some cases used to set the values to another spreadsheet origin. This property is used to reset all the CSS properties in a document.Syntax: all: initial|inherit|unset|re 3 min read CSS animation-delay Property The animation-delay property specifies a delay for the start of an animation. Defined in seconds (s) or milliseconds (ms), this value determines how long to wait before beginning the animation. Negative values start the animation as if it had already been playing for the specified duration.Syntaxani 3 min read CSS animation-direction Property The animation-direction CSS property sets whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward and backward. It controls the visual flow and repetition behavior of animations in web pages, enhancing dynamic content presentation.Syntaxan 4 min read CSS animation-duration Property The animation-duration property in CSS is essential for controlling the length of time an animation takes to complete one cycle, making it a vital tool for creating dynamic and engaging web designs.Syntax:animation-duration: time | initial | inherit;Property Value:time: This value is used to specify 3 min read Like