# Aligning images

**URL:** <https://forum.code.org/t/aligning-images/38124>\
**Category:** CS Discoveries\
**Tags:** csd-unit-2\
**Created:** [May 17, 2023, 3:47pm UTC](https://forum.code.org/t/aligning-images/38124 "2023-05-17T15:47:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GordonBrune](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gordonbrune/32/4752_2.png) [@GordonBrune](https://forum.code.org/u/GordonBrune)\
**Post date:** [May 17, 2023, 3:47pm UTC](https://forum.code.org/t/aligning-images/38124/1 "2023-05-17T15:47:17Z")

</div>

Is there a way to align an image (to the center, to the right, to the left).  
I know there is a way to do it with classes but students just has one images and is not on the classes lesson yet.

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [May 17, 2023, 4:56pm UTC](https://forum.code.org/t/aligning-images/38124/2 "2023-05-17T16:56:28Z")

</div>

@GordonBrune ,

There are a number of ways to center an image. Perhaps one of the easier ones for a beginner would be to put it inside a container (such as a div, but could be any container)  
and then use css to style that container with text-align: center;

This would also work for left or right alignment.

Here’s a working example:

[https://codeprojects.org/projects/weblab/syGdp8oCGdosriCofyYhImomvGg5HiN9pIq56pYs44A](https://codeprojects.org/projects/weblab/syGdp8oCGdosriCofyYhImomvGg5HiN9pIq56pYs44A)

good luck!

Mike

---

<div class="post-metadata">

**Author:** ![edavis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/edavis/32/4927_2.png) [@edavis](https://forum.code.org/u/edavis)\
**Post date:** [May 18, 2023, 12:56am UTC](https://forum.code.org/t/aligning-images/38124/3 "2023-05-18T00:56:10Z")

</div>

Students also learn how to use the float property in Lesson 11. This won’t help the student center an image, but it is an easy way to move it left or right of text.
