HTML element position | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

HTML element position

How can I manipulate the position of my html elements? For example how can I move a group of texts like the “hello world” text in the sample code to another location in the page https://code.sololearn.com/WKhxtaRih1sq/?ref=app

5th May 2020, 5:44 PM
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu)
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu) - avatar
8 Answers
+ 6
Nwanakwoakwo Wid'obiagu You can use align attribute like this: <div align="center"> </div> Change it to left or right where you want to align.
5th May 2020, 6:38 PM
NightFox
NightFox - avatar
+ 3
It is possible by simply changing the position of your elements using CSS. See this: https://www.w3schools.com/css/css_positioning.asp The basic positioning can be easily done by using align in HTML, but using positioning and alignment in CSS is more recommended.
5th May 2020, 6:02 PM
NightFox
NightFox - avatar
+ 2
Nwanakwoakwo Wid'obiagu Here you go bro :)) https://code.sololearn.com/WI2KXqITPFFx/?ref=app If you want an image to be dragged just put it inside the div :))
5th May 2020, 6:17 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 2
Nwanakwoakwo Wid'obiagu Oh I got you now :)) This how you do it : <div style="position: absolute; left: 50px; top: 50px;">Hello World</div> The text will appear at 50 pixels from the left and 50 pixels from the top :)) You can set it to any value and the div will be positioned according to what you set!
5th May 2020, 6:35 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
thank you Marzan im having trouble accessibg that link please have u got another i can use?
5th May 2020, 6:04 PM
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu)
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu) - avatar
+ 1
thank u so much guys ill try them out
5th May 2020, 6:41 PM
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu)
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu) - avatar
0
Arb Rahim Badsa hi i understand this but i would like to know how to set the atrributes for the div tag so that the elements inside appear where i want them on the web page
5th May 2020, 6:28 PM
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu)
Nwanakwoakwo Wid'obiagu (kenneth Anyanwu) - avatar