FAQ: Typography - Text Layout

This community-built FAQ covers the “Text Layout” exercise from the lesson “Typography”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Build a Website with HTML, CSS, and Github Pages
Full-Stack Engineer
Front-End Engineer

Learn CSS

FAQs on the exercise Text Layout

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

This lesson, like the HTML course, should have questions at the end of the exercise.

How do I convert between PX, EM, %, and PT?

Note: 16px is used as the body text size in all conversions because that is the browser default. You will change 16px to your base text size.

PX to EM
Formula: size in pixels / parent size in pixels
Example: 12px / 16px = .75em

PX to %
Formula: size in pixels / parent size in pixels * 100
Example: 12px / 16px * 100 = 75%

PX to PT
Formula: size in pixels * (points per inch / pixels per inch)
Example: 16px * (72pt / 96px) = 12pt

EM to PX
Formula: size in EMs * parent size in pixels
Example: .75em * 16px = 12px

EM to %
Formula: size in EMs * 100
Example: .75em * 100 = 75%

4 Likes

Can you tell me what em means? Example: letter-spacing: 0.3em.
No where in the paragraph explaining text layout did I find where is tells you what em mean vs the pixel size. I know the answer is going to simple, but I think a note should be added the explain what em means, as opposed to searching online for an answer.

Kind regards.

James.

3 Likes

This would help
Here is the solution.

https://discuss.codecademy.com/t/solution-for-typography-project/605617

Is is a good question! it is really confusing!
I dont know either what EM mean! they should explain!

Is the unitless value the same as em in line-height?

The lesson for line-height states:

Generally, the unitless value is preferred since it is responsive based on the current font size. In other words, if the line-height is specified by a unitless number, changing the font size will automatically readjust the line height.

Does this mean that the default unit for unitless values is em?

Here is an explanation of all of the units css uses to express length.

‘em’ is included in the document:

https://www.w3.org/Style/Examples/007/units.en.html

p {
  line-height: 1.4;
}

When no unit is specified, what unit is implied, and how is it different from em (which is also a unit relative to the font size)?

In other words, if the line-height is specified by a unitless number, changing the font size will automatically readjust the line height.

shouldn’t this be the same for em? :stuck_out_tongue:

Question about letter-spacing in headlines using a font with poor kerning-pairs. In InDesign or Illustrator, I go in and kern between individual letters as needed. Is this something we can do in CSS, or would that be needlessly complicated, and it would be better to create a jpg in Illustrator an import as an image? Thanks!

For the unitless values in this exercise, what is the range and with do values above and below 1.0 indicate?

Hello,

From what I understand it’s like this

If we take the line spacing as a reference, the value of 1 means that the line space will be big as the default font size that’s set by the browser. The default value is 16px, so that means that a line space will be 16 pixels in height. In the case where there’s a CSS rule for the font in that specific element, let’s say 20px, then the line height will be 20px.

So following this logic, setting the unitless value to go above 1 will increase the space between the rows. If you remember, using 1,5 and double line spacing in Word and Google Docs is basically this.

If you set the value below 1, this means that the line space will be too small for the font size and you will experience overlapping of the text in between rows.

In general, having a unitless value for any property means that the size will be determined by a default setting or a rule that’s been set for that element.

Now how is this different than em, beats me. If someone knows, please do explain

Regarding the question on range - I don’t know :slight_smile:

There is no upper-limit for the unitless value of line-height. However, it is common to see the range lies between 1.0 - 3.0. A range below 1.0 might result in overlapping between text of different lines whilst a range greater than 3.0 might result in presentation-wise issues (this includes both readability and maintainability).