How can I style a paragraph to have a specific number of text columns of fixed-width text in CSS? I know I could style it that way manually and use <pre> tags, but I was hoping that there is a way to do it in CSS.
How can I style a paragraph to have a specific number of text columns of fixed-width text in CSS? I know I could style it that way manually and use <pre> tags, but I was hoping that there is a way to do it in CSS.
If you fix the width of the div and use a non-proportional font; would that not work?
I want the width of the paragraph to expand if text grows bigger, like if someone were to ctrl+. Every line having 80 characters of a fixed-width font in the paragraph, no matter what.
I know how to make a flexible-width element; I need to know how to make it have a set number of characters per line.
This means RIGID not FLEXIBLE.
A set number of characters per line suggests a fixed width not a flexible one, surely.
(80 x 14)px per line/each line/ means (80 x 14)px each line. NO VARIATION.
You can't have it both ways. Can you?
If you do a control+ it expands the text, but still keeps the same number per line. It just adds the scroll bar.
A set number of characters per line suggests a fixed width not a flexible one, surely.
(80 x 14)px per line/each line/ means (80 x 14)px each line. NO VARIATION.
You can't have it both ways. Can you?
If you do a control+ it expands the text, but still keeps the same number per line. It just adds the scroll bar.
Try it on any page of this forum.
Frank
Okay, my goal is this: I have a paragraph within a div. The div expands to the width of its contents, no problem. The text in the paragraph needs to be 80 characters per line, NO MATTER WHAT. Is that possible to do with CSS?
Okay, my goal is this: I have a paragraph within a div. The div expands to the width of its contents, no problem. The text in the paragraph needs to be 80 characters per line, NO MATTER WHAT. Is that possible to do with CSS?
As far as I know, there's no real way to do that with just CSS. You can come close, by defining the width of the container in ems, which will make the width relative to the font-size, but since ems are calculated by font height the numbers aren't exact and will need some fudging:
Code:
#container {
font-family: courier;
width: 50em; /* more or less 80 chars wide on Safari with a default text size */
}
A better thing to do, I think, if it were absolutely necessary to keep a strict character count, would be to use an em-defined width in your CSS but Javascript to count the characters as they are displayed and wrap the text automatically.
Thank you very much. In the comments of your first link, there is a suggesting to use the unit ex, which is the height of an X in the font. I think it's just what I'm looking for.