World Wild Web > ☔︎ ∙ I need Help!
How to allign
SilkSkull:
How do I align my text the the centre of a page? I know that it involves CSS but I can't figure out how to work <stlye> for the life of me, here is my code as of now:
https://ibb.c:ha:7XHkqjf
Guest:
If you just want to centre-align the text itself, add style="text-align: center;" to your HTML element that holds the text (<div>, <p>, etc.)
If you want to centre an element horizontally on the page, like a <div>, you can do so by setting a width that's less than 100% of its parent container and then adding style="margin: 0 auto;".
Those are the two easiest solutions to the most common use cases. There are a lot of different ways to position things on the page, but since you're just starting out you probably don't want to get into flex or grid yet.
SilkSkull:
--- Quote from: MamboGator on October 02, 2022 @192.25 ---If you just want to centre-align the text itself, add style="text-align: center;" to your HTML element that holds the text (<div>, <p>, etc.)
If you want to centre an element horizontally on the page, like a <div>, you can do so by setting a width that's less than 100% of its parent container and then adding style="margin: 0 auto;".
Those are the two easiest solutions to the most common use cases. There are a lot of different ways to position things on the page, but since you're just starting out you probably don't want to get into flex or grid yet.
--- End quote ---
So I followed what you said and it is still sticking to the left side of the page, did I enter the <style> tag wrong?
My New Code:
https://ibb.c:ha:7XHkqjf
Site:
https://ibb.c:ha:vQSp0Fb
Gans:
There is a <center>...</center> tag.
It's obsolete, but it works.
https://www.w3.org/TR/html401/present/graphics.html#edef-CENTER
Melooon:
--- Quote from: SilkSkull on October 02, 2022 @198.54 ---My New Code:
https://ibb.c:ha:7XHkqjf
--- End quote ---
I think thats the same code image you posted already :omg:k: (You could also paste the code here in code tags)
--- Code: ---like this
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version