# Problem with Next/Previous link formatting problem

**URL:** <https://community.hubspot.com/t/problem-with-next-previous-link-formatting-problem/4048>\
**Category:** CMS Development\
**Created:** [December 1, 2017, 1:20pm UTC](https://community.hubspot.com/t/problem-with-next-previous-link-formatting-problem/4048 "2017-12-01T13:20:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickbyrd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rickbyrd/32/52876_2.png) [@rickbyrd](https://community.hubspot.com/u/rickbyrd)\
**Post date:** [December 1, 2017, 1:20pm UTC](https://community.hubspot.com/t/problem-with-next-previous-link-formatting-problem/4048/1 "2017-12-01T13:20:28Z")

</div>

I am using the following code to create Next and Previous links at the bottom of each blog post:  
\<div class=“list-pagination”\>  
{% if content.next\_post\_slug %}  
\<a class=“pagination-btn list-prev-post” href=“/{{ content.next\_post\_slug }}”\>Previous\</a\>  
{% endif %}  
{% if content.previous\_post\_slug %}  
\<a class=“pagination-btn list-next-post” href=“/{{ content.previous\_post\_slug }}”\>Next\</a\>  
{% endif %}  
\</div\>  
The problem I am having is the words Next and Previous are next to each other. I would like to have the word Previous on the other side of the page but I am not sure how. See link below for the current look - [Perspective on Payday Loans](https://www.bigpictureloans.com/blog/perspective-on-payday-loans)  
Also, I would like to potentially add an image along with the name of the post instead of just the words Next and Previous. See link for example - [10 Digital Assets Every Estate Plan Must Consider](https://www.altusfinancial.com.au/latest-news-1/10-digital-assets-every-estate-plan-must-consider)  
Is this even possible?  
Thanks!  
- Rick

---

<div class="post-metadata">

**Author:** ![Jsum](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jsum/32/20405_2.png) [@Jsum](https://community.hubspot.com/u/Jsum)\
**Post date:** [December 1, 2017, 8:42pm UTC](https://community.hubspot.com/t/problem-with-next-previous-link-formatting-problem/4048/2 "2017-12-01T20:42:03Z")

</div>

@rickbyrd,

This is one of those questions that has many answers and is based on how you have the page coded. I can give you a general example though.

Here is your markup:

```auto
<div class="list-pagination">
	{% if content.next_post_slug %}
		<a class="pagination-btn list-prev-post" href="/{{ content.next_post_slug }}">Previous</a>
	{% endif %}
 {% if content.previous_post_slug %}
 <a class="pagination-btn list-next-post" href="/{{ content.previous_post_slug }}">Next</a>
 {% endif %}
</div>

```

Notice the text in blue, these are the relevant classes.

First clear floats on your wrapper. According to[css tricks](https://css-tricks.com/snippets/css/clear-fix/) this is currently the best way to clear floats:

`.list-pagination:after { content: ""; display: table; clear: both; }`

Next you just want to float previous to the left and next to the right:

```auto
.list-next-post { float: right; }

.list-previous-post { float: left; }

```

and that’s really all it should take.

---

<div class="post-metadata">

**Author:** ![rickbyrd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rickbyrd/32/52876_2.png) [@rickbyrd](https://community.hubspot.com/u/rickbyrd)\
**Post date:** [December 4, 2017, 12:56pm UTC](https://community.hubspot.com/t/problem-with-next-previous-link-formatting-problem/4048/3 "2017-12-04T12:56:40Z")

</div>

Jsum,

Thanks for the information! I’m a newbie to all of this. If I understand you correctly, I should replace the relevant classes with the new code for the floating. Like below:

`<div class=".list-pagination:after { content: ""; display: table; clear: both; }"> {% if content.next_post_slug %} <a class="pagination-btn .list-previous-post { float: left; }" href="/{{ content.next_post_slug }}">Previous</a> {% endif %} {% if content.previous_post_slug %} <a class="pagination-btn .list-next-post { float: right; }" href="/{{ content.previous_post_slug }}">Next</a> {% endif %} </div>I tired this and it did not change anything so I most likely did this incorrectly.`

---

<div class="post-metadata">

**Author:** ![Jsum](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jsum/32/20405_2.png) [@Jsum](https://community.hubspot.com/u/Jsum)\
**Post date:** [December 4, 2017, 1:01pm UTC](https://community.hubspot.com/t/problem-with-next-previous-link-formatting-problem/4048/4 "2017-12-04T13:01:52Z")

</div>

@rickbyrd,

No those are css declarations. Keep the class names as is, and place the css in your style sheet, or in the head of the template wrapped in \<style\>\</style\> tags.

---

<div class="post-metadata">

**Author:** ![rickbyrd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rickbyrd/32/52876_2.png) [@rickbyrd](https://community.hubspot.com/u/rickbyrd)\
**Post date:** [December 4, 2017, 1:35pm UTC](https://community.hubspot.com/t/problem-with-next-previous-link-formatting-problem/4048/5 "2017-12-04T13:35:55Z")

</div>

My bad! That makes more sense. Thanks for helping me out!

Rick
