burger menu icon
WillMaster

WillMaster > LibraryWeb Page and Site Features

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Simple CSS Rotate

For a simple rotate, I generally use the CSS rotate property. I specify how many degrees or what fraction of a turn, and I'm good to go.

An example is a download arrow. Just this morning, I needed an arrow that could be interpreted as a download arrow. I wanted a character, not an image. All I found was ⇪. I needed it to point down, so I rotated it half a turn.
was the result. (The CSS is rotate:.5turn;)

Images can be rotated. Paragraphs, divs, even entire tables can be rotated. To rotate individual characters, they need to be in a div (or a table or other block container). To rotate a character within a line of text, specify the display:inline-block; CSS declaration for the div containing the character.

Rotation is clockwise. Both rotate:45deg; and rotate:.125turn; will rotate something an eighth of a full rotation. Although I rarely use radians, you can specify the amount of rotation that way. rotate:0.78539812rad; will rotate something an eighth of a full rotation.

<div style="rotate:45deg;">A</div>
A
<div style="rotate:.125turn;">A</div>
A
<div style="rotate:0.78539812rad;">A</div>
A

As mentioned, rotation is clockwise. To make something appear to be rotated counterclockwise 1/8 of a rotation, rotate it clockwise 7/8. Use rotate:315deg; or rotate:.875turn; or, if you prefer radians, rotate:5.49778688rad; can be used.

<div style="rotate:315deg;">A</div>
A
<div style="rotate:.875turn;">A</div>
A
<div style="rotate:5.49778688rad;">A</div>
A

Unless you specify otherwise, the rotate property will rotate from the middle. In other words, the axle is the center of the image or div or whatever you are rotating.

The rotate property is actually quite sophisticated. If you wander away from the simple implementation suggested above, rotate:_______(deg|turn|rad), then it can get non-simple pretty quick. MDN has a page dedicated to the various ways rotate can be used.

For everyday use, the simple rotate mentioned above is my go-to.

(This content first appeared in Possibilities newsletter.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2026 Will Bontrager Software LLC