how to center text on label?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By godot111

I just made a new Godot project and created a Label with text. Even with Align: center the text stays top left when I run the game.

edit: alright I solved it, Top and Left margin of 100, but still not centered

:bust_in_silhouette: Reply From: vspin

The label should center within its width. So, for example, if you anchor the label to the right and left of its parent with zero margin, the label will be centered inside the parent.

Try scaling up the label’s width considerably, and see if it centers the text within its width. Be sure to remove your 100 margin.

:bust_in_silhouette: Reply From: hinasis

Place it inside a container, Margin, Panel, Hbox, Vbox, are good options.
Then in the label’s size flags, unmark “fill”, in both horizontal and vertical, and mark only keep centered in both. (Don’t confuse align parameters from label’s text one with the one you should tweek, the every control 's size flags.

Option two, place it in a center container, and make sure fill and expand size flags are not marked.

Correct awnser is [center] your text [/center]