How to align an image? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

How to align an image?

the title says it all how?

30th Apr 2017, 5:01 AM
Krieg7
Krieg7 - avatar
8 Answers
+ 10
Strictly, alignement is done by setting the 'text-align' css property of the element container ( the block containing the image, the parent tag element of the <img> one ), as default behavior of <img> html element is to be treated as text content ( inlined with, in the text stream ). On the other hand, the 'float' css property of an element define another kind of alignement ( only right and left, not center contrarly to 'text-align' ), with the behavior of retrieving the element from the normal stream, align it on a side of the container, and let the normal stream wrap around the element ( allowing text to side next to the image on many lines, instead having the image height imposing the line-height to the text content ^^ ).
30th Apr 2017, 5:58 AM
visph
visph - avatar
+ 15
inside <p> tag, Lol
1st May 2017, 12:50 AM
JΞΜΔ 🇨🇩👑
JΞΜΔ  🇨🇩👑 - avatar
+ 13
...the bane of css's existence...
30th Apr 2017, 5:12 AM
Ahri Fox
Ahri Fox - avatar
+ 11
right sorry i havent reached that lesson yet i was about to study that lesson now XD anyways thanks
30th Apr 2017, 5:17 AM
Krieg7
Krieg7 - avatar
+ 10
So is there a way or no?
30th Apr 2017, 5:13 AM
Krieg7
Krieg7 - avatar
+ 5
Thanks!
30th Apr 2017, 11:16 PM
Krieg7
Krieg7 - avatar
+ 2
float: left/right
30th Apr 2017, 5:16 AM
Calviղ
Calviղ - avatar
+ 1
but u can take your img into P after p give style display in-line block and align center if u want to have it in center but most comfortable use margin
30th Apr 2017, 2:05 PM
Kristina Hakobyan
Kristina Hakobyan - avatar