How do I make it so that something I put in is centered on a glitch website?

I don’t know how I would position it in the center.

That is mainly a CSS question.

Hey @DiscordUserCrab,

It depends on what you are trying to center. If it’s text, you could add the following CSS:

p {
   text-align: center;
}

Or as a workaround, to center align anything in your webpage, just wrap those elements in a <center></center> tag, although it is not supported in HTML5.

Two other ways which you can try are as follows –

  1. try adding margin: 0 auto to the element. What this means is, the margin on to the top and bottom of the element is zero (you can change that to be whatever you want) and on the right and the left is “auto.” This will center some elements.
  2. If that doesn’t work, find the “parent element”, or, the element which contains the element you want to center. Add these css styles to that element:
display: flex;
align-items: center; 
justify-content: center;

and it may do what you’re hoping for! Feel free to let me know if these don’t work, or if I could clarify any part of it further!

1 Like

There are two main approaches:

body {
  text-align: center;
}

Alternatively, you can do it more granularly, and do it per html tag:

<center><img src="#yoururl"></center>

I think it’s important to know both ways, because sometimes I don’t want the entire website to be centered, though that’s more a style choice.

2 Likes

Another method would be.
width: 50%; transform: translate(50%, 50%);

Read the following;


1 Like