Zaloguj | Zarejestruj | FAQ
Anonymous

Unable to center text with "text-align:center"

+ Odpowiedz

Posty: 3 Strona 1 z 1


Unable to center text with "text-align:center"

przez Fangorn » So cze 28, 2014 2:33 pm

Whilst I am able to center text with the following code:
<p style="text-align:center"> Hello! </p>

I am unable to center text with the following code:
<p style="position:absolute;top:160px;text-align:center;"> Hello! </p>

In the latter example the text results left-aligned.
I have to start writing at least 160px from the top, because of a picture, so I decided to use the 'position' property. Howevert the browser ignores my instruction to center-align my text. Why?

Many thanks in advance
Avatar użytkownika

Fangorn

  • Posty: 17
  • Dołączył(a): Wt cze 24, 2014 3:28 pm

Re: Unable to center text with "text-align:center"

przez Fangorn » So cze 28, 2014 8:32 pm

Many thanks for your reply CubeSquare.
I am a newbie on html, just started, so at first I did not understand much of your code.
I read the tutorial on html.net and wanted to try something myself.
I have to understand div and container, first of all, as far as I understood.
To tell the truth, I used position:absolute without knowing much of its meaning, only because I found it in an example of the tutorial and wanted to try something myself with a picture and some text below.
I will try to study with patience what you wrote. There is a logic in it and I want to understand it.
If you have any suggestion about how to procede with my study, I'll welcome it.
Thanks!
Avatar użytkownika

Fangorn

  • Posty: 17
  • Dołączył(a): Wt cze 24, 2014 3:28 pm

Re: Unable to center text with "text-align:center"

przez Fangorn » N cze 29, 2014 6:29 am

Good, then, I will keep studying which is a bit of fun moreover :)
Avatar użytkownika

Fangorn

  • Posty: 17
  • Dołączył(a): Wt cze 24, 2014 3:28 pm


+ Odpowiedz

Strona 1 z 1