how to center text in css

/* To center text, you need to use text-align. */

.centerText {
  text-align: center; /* This puts the text into the center of the 
  screen. */
}

/* There are also other things that you can use in text-align:
left, right, and justify. Left and right make the test align to the
right or left of the screen, while justify makes the text align both
sides by spreading out spaces between some words and squishing others. */

3.75
4

                                    body {
  text-align: center;
}

3.75 (4 Votes)
0
4
10

                                    text-align: center;

4 (10 Votes)
0
0
0
Hatshepsut 120 points

                                    .class {
	text-align: center;
}

0
0
4.29
7

                                    /* Character-based alignment in a table column */

text-align: center;

/* The inline contents are centered within the line box. */

4.29 (7 Votes)
0
4
4
Ouida 110 points

                                    /* Using flex to center anything*/
.parent{
  display: flex;
  justify-content: center; /* Centering Horizantly */
  align-items: center; /* Centering Vertically */
  /* Every element inside this div will be centered*/
}
/* Using Line Height*/
.main-div{
  width: 50%;
  height: 40px;
}
.main-div p{
  line-height: 40px; /* Same as parent height*/
  /* p will be centered vertically inside its parent div*/
}
/* CSS Property */
p{
  text-align: center;
}

4 (4 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
get text in center css css code center text css div text center how to centralize text in css text position center css how to center text a font text align center css how to aline the text to the center in css css text allign centere css how do I center text css styling to center text centering a text css how do i center text in css center text in css how to put text in center with css text center div css css centre align text text in center css css text center class centered text css text center texte aligne center css style text center align text css text-align center css align text to center css css text align horizontal center css text center text align center in css text align centre in css css put text center set text to center html class text-center how to align text center css aligning center text in css htnl centre text in div align text in div to right how to put a text in center css center text in div css how to center text html css style align center css text align center text aling css text alignment in center css html align right text-align center center paragraph text css set text center css align text top center css how to make text in the center css align-text center text centered align center text css ode javascript center text center align font css align text element center css css align right align left in css how to center text with css place text center of div css text on right side of page center font align text to center center text allign text center css style for center alignment how to move a text to the center text allign css how to textallign center in css how to align text in the center css to have text in cnetre html text align text justify center test align center css align text center how to put text in center in html center h1 css text on the right side html center text in <p> text align right css left align css text in center center text in paragraph css css font float css text right justifies align right css text center in css centre font css how to move text to the center in css css code to center text position text in center of page css sytle hwo to centre text css css align center text center css text align text center css text align css w3schools how do i center text css css centre text css align text in center of div aline text to center in css move the text to center in css center a text css inline css center text css center divs how to center text oin css how to make text center in css html stylke center css center content in div center text in a div css bring content to center css css ppositioon elements inside div center justify text css how do i align an item in the middle of the page css? align content in a div css css paragraph center all text alignment css css center element in div center title and css center text horizontally css center text css code html text alignment css body center centre text css align paragraph css font center css how to set all item in div go to center in css body centered css move div to center of page css hcss text-align: center css tex align how to centralize a text in a div tag in html html align center div content make text center how to center an html element css text align middle how to align a div tag at the centre using css center command css how to center texthtml css center the body css text center cs how to align text in div center how to put items in the center css style div align center make text center css align div items center css align everything right allign center in css align content inside div child div center of parent div center aling text css center text in a DIV link to center in css text align center style align center html center align text css center align div style center style how to center a div css how to put a element in the middle css centering text text center css how to make text centered on the page css text align css center content css css centre content in div css class to center middle of page position section in center of html page css css text position center center in html and css how to center text inside div css html css div in center of page aligh text in a css css text-align how to center text css css align content center in div css code to align center how to center a body in css css text centre how to change text alignment in css align text in center in css css text align center in css css font right css text alignment css style align center css how to make text center how to center a padding on a page css text align center css css center text completely center text css center text css center a div css css put text in middle how to centre tect in css how to center text in css align everything to centre css css center align text css how to put a div in the center css align text center how to put text at the center in css css how to center how to align content to center in css css align text css center class css center box on page put element in center of div css how to center font in css
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source