Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate Photoshop letter spacing in css px or rem?

Anyone have any idea to how to calculate photoshop letter spacing in css px or rem. Example: I have 140 letter spacing in photoshop. Now, what should be this on CSS? Or is there any way to do this with sass?

like image 832
Harden Rahul Avatar asked Oct 28 '17 06:10

Harden Rahul


People also ask

How do you calculate letter-spacing in Photoshop?

Photoshop to Letter Spacing CSS Converterfunction cal() { let input = parseInt( $( '#tracking-value' ). val() ); if ( $( '#em' ).is( ':checked' ) ) { $( '#the-value' ). html( (input / 1000) + 'em;' ); $( '.

Should I use REM for letter-spacing?

Using font-relative values (em or rem) is recommended, so that the letter-spacing will increase or decrease by an appropriate amount if the font-size is changed. The length value is added to (or subtracted from) the browsers default spacing (which is based on the font metrics.)


1 Answers

Dividing the value in Photoshop by 1000 and setting that result in em gives pixel-perfect results.

For example, let's say in Photoshop you have a letter spacing of 50, the resulting css would be letter-spacing: 0.05em.

Create a simple function to help you do the math everytime:

@function letter-spacing($ps-value) {
    @return ($ps-value / 1000) * 1em
}
like image 178
Steve Avatar answered Oct 14 '22 06:10

Steve