What property in CSS is used to center text?

Prepare for the WebXam Web Development Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

The property used in CSS to center text is the text-align property. This property specifies the horizontal alignment of inline content in a block-level element. When you set the text-align property to "center," it aligns the text horizontally in the center of its containing block.

For example, if you have a paragraph of text inside a div and you apply the CSS rule text-align: center; to that div, the text will be centered within the div's width, providing a visually appealing layout.

The other options aren't recognized CSS properties for centering text. "Center-align" and "align-text" do not exist in CSS and would not produce any effect on text alignment. The "justify" property is used to align text evenly along both the left and right margins, creating a clean look, but it does not center text. Therefore, text-align is the correct and effective property for centering text within its parent element.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy