# Unit 2 text wrap?

**URL:** <https://forum.code.org/t/unit-2-text-wrap/38528>\
**Category:** CS Discoveries\
**Tags:** csd-unit-2\
**Created:** [October 17, 2023, 3:03pm UTC](https://forum.code.org/t/unit-2-text-wrap/38528 "2023-10-17T15:03:36Z")\
**Posts on this page:** 4\
**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:** [October 17, 2023, 3:03pm UTC](https://forum.code.org/t/unit-2-text-wrap/38528/1 "2023-10-17T15:03:36Z")

</div>

Student wants text to appear to right of the image above the text.  
We tried using flota in the CSS for the image and the text but…  
[https://codeprojects.org/projects/weblab/bj\_u12bDpQPzi1kRdSwRPvPzcKGKZ0sWynO175Ayov4](https://codeprojects.org/projects/weblab/bj_u12bDpQPzi1kRdSwRPvPzcKGKZ0sWynO175Ayov4)

---

<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:** [October 17, 2023, 5:41pm UTC](https://forum.code.org/t/unit-2-text-wrap/38528/2 "2023-10-17T17:41:52Z")

</div>

For some reason, it wouldn’t let me see the code. Sometimes students think they should apply the float to the text since that’s what they want to move, but if you use the float:left; on the image, it should put the image to the left and the text to the right. Give it a shot and let us know!

---

<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:** [October 17, 2023, 9:57pm UTC](https://forum.code.org/t/unit-2-text-wrap/38528/3 "2023-10-17T21:57:35Z")

</div>

Hello again, @GordonBrune ,

Let me take a stab at this one … [Code.org](http://Code.org) recently posted in the forum that they are looking into possibly revising the curriculum for unit 2. I applied and I don’t know for sure what they are looking for or what changes they are looking to make, but if I had my say, I’d advocate for removing float from the lessons as it is a pretty clunky way to layout elements on a page. I searched for how to use float just to see what I would find and most of the articles are over 5 years old… that’s because there are [better ways to accomplish the task.](https://css-tricks.com/is-css-float-deprecated/)

So, here are two answers.

1, your student floated the image left and the text right. Floating both lifts both off the page and kind of doesn’t work. You only need to float the image. [This remix](https://codeprojects.org/projects/weblab/53arxk1u-HBEfVTkfI63k3iwiLa8frUpIU8lA4IcbkU) shows the “float: right” removed and the text does go to the right of the image.

 ![Screenshot 2023-10-17 at 3.44.44 PM](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/d/d442fa9de646fbd2324f66a381aec95bf3b3ba45.jpeg)

However, the next question is going to be, “but yeah, it still doesn’t look great” and I fully agree with that, because the text isn’t very long, so after the text finishes, the rest of the page flows below and it’s just not very well laid out so here is what I show my students. As is mentioned in the article above, there are better ways. For a simple example like this one, flexbox is the easiest.

The basics are that you create a container around your image and your text. I like using the `<figure>` tags, but you can also use a `<div>`.

 ![Screenshot 2023-10-17 at 3.58.59 PM](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/c/c2a5ae73b1e7114254b5445e3cfafac4f684e13e.png)

The styling is where the magic happens.

![Screenshot 2023-10-17 at 3.59.21 PM](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/0/0f9ae95d3bd7f4d0f387ed21ccd40400dddb7cbf.png)

Now, you get [these results instead.](https://codeprojects.org/projects/weblab/cnpFSwnlNjr_ScpCQeUz27DoJU4EHimY1VlNrgXTc2s)

 ![Screenshot 2023-10-17 at 4.01.51 PM](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/e/eae97893cf3f33638c14ce15e30e4bb47e253e54.png)

I did change the text to white so it was easier to see and I added a 2nd paragraph.

So, it is a few more lines of code, but it is a lot more clean visually after it is done and you don’t even have to float anything (I took the float out of the code on the 2nd one). You could also alternate left and right by just changing the order of the code inside the figure tags. If the paragraph is first, it will be on the left and the image on the right. You can also add three images inside one container and the three will take up equal space across the page … and there’s even more you can do.

So, I hope this isn’t overly complicated, and I could probably present it more clearly, but let me know if this may help.

Mike

---

<div class="post-metadata">

**Author:** ![mriley](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mriley](https://forum.code.org/u/mriley)\
**Post date:** [October 18, 2023, 5:59pm UTC](https://forum.code.org/t/unit-2-text-wrap/38528/4 "2023-10-18T17:59:48Z")

</div>

This would be an awesome addition to the unit!!  
Perhaps a stand alone lesson?
