Css line height wrap text. It is often set in a unitless value (e.

 

Css line height wrap text Line element gets pushed down when text Aug 27, 2020 · I am trying to add line-height to my text inside my div so that when the text wraps in mobile view, it can be consistent with my margins. word-wrap { /* Warning: Needed for oldIE support, but words are broken up letter-by-letter */ -ms-word-break: break-all; word-break: break-all; /* Non standard for webkit */ word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; -ms-hyphens: auto; hyphens: auto; } Apr 28, 2015 · So I used a little hack that involves setting clamp's line count to 3 and setting the line-height CSS property of the wrapping element to exactly be 1 / 3 rd of the element's height. It's commonly used to set the distance between lines of text. Font size. 75em. But, given your question, this is likely not the case. I am using textarea for it: <Input /> Works for Internet Explorer 8+, Firefox 6+, iOS 4. I would like to get a different height for each \n lines without using individual div or br. Break-word means the text will wrap to next line. 5+ */ overflow-wrap: break-word; /* Renamed property in CSS3 draft spec */ But this won't worked then I try this- white-space: normal; Aug 3, 2017 · Plus the width of the icon, they cannot fit in one line. HTML5 spec: 4. 4;) so that it is proportional to the font-size. CSS ellipsis on second line. While our heading classes (e. The only problem is height and width are controlled by the content, which in this case is collapsed. Try this : line-height:25px; A browser will try to flow your text inline within the box until it reaches its maximum allowed width of 250px, then wrap to the next and subsequent lines any text that cannot fit on the first line. box-decoration-break: clone; Each box fragment is rendered independently with the specified border, padding and margin wrapping each fragment. Whereas font-size sets the actual size of the font. A text with line-height: 1 will be compact and will reach the top and bottom of the surrounding elements. First, line-height applied to block element define the minimum height of the line box. Oct 13, 2010 · Is it possible to limit a text length to "n" lines using CSS (or cut it when overflows vertically). 7 times the font-height is much less than the height of the strut, the line height is determined by the height of the strut, since the line box must wholly contain its inline boxes. Viewed 34k times text-bottom; line-height: 1. * By default, data_table tds do not wrap. 1 * 3em = 3. Aug 30, 2019 · The horizontal padding only applies to the very beginning and end of the text where it wraps, but I want it to apply on every line. See if this does what you want: li { padding: 10px 0 0 0; margin: 30px 0; line-height: 10px; } The line-height property specifies the height of a line. Class {height:auto;} if you use width:auto, your webpage will distort and it won't look so good, so you could use width if you use a fixed width like . 6. Is there a way in CSS that I can cause the 3rd element in this list, which is longer than the rest, to wrap to a new line if it extends over 100 characters? so that the rest of the text is on the next line? Jul 18, 2017 · I'm trying to wrap my text in my slide menu. h1–. wrappa Jun 22, 2012 · If you have line-height set in ems, CSS Line Height - bottom only. How to w That depends on your definition of a single-line height, since there isn't a CSS unit that corresponds to the computed line height of an element. The important line is background-repeat: no-repeat;. 2 Text (type=text) state and Search state (type=search) The input element represents a one line plain text edit control for the element's value. Jul 19, 2011 · The text IS wrapping; however, you've set a height. May 20, 2011 · The CSS property 'line-height' actually accepts a pure numerical value, which will work out the line height based on the font size set. clamped-2 W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Note how . line element needs to be half of line-height. You are putting line-height here only to center your text in the middle. But problem is that, using CSS text-overflow:ellipsis will cut the whole long text into one line text and place these dots where more text can be written into in below space. 1+ and Chrome 13+. 2. When the text is long, I want this overflowing text to disappear. 61803399), then you could set this as the line height in the body. These divs have a max-width of 140px, and contain text that cause them to vary in width up to that size. Feb 4, 2020 · One example is the CSS line-height property which sets the distance between two baselines of wrapped text. Check this post for some ideas for workarounds Share W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Just note that a combination of three properties are used to make it happen:. What is overflowing text? In CSS, if you have an unbreakable string such as a very long word, by default it will overflow any container that is too small for it in the inline direction. I'm OK with the border-radius not being at the line-break points of every line, but I need the padding to apply. May 13, 2009 · If you only have a single word or a single line of text, there is a clever way to vertically center it in a block with CSS. If supported by Browsers, the following should work:. initial: It sets this property to its default value. But what if we want to introduce the ellipsis not on the first line but somewhere, say, the third line of text? That’s where line-clamp comes into play. Jun 30, 2014 · Unfortunately, there is currently no way in CSS to tune line breaking rules by specifying, for example, that a line break is permitted after a certain character wherever it appears in the text. Jun 27, 2016 · But I need to achieve next result if text in span doesn't fit the line move whole span to the next line. En elementos en linea no reemplazables, especifica la altura que se usa para calcular la altura de la casila encuadrada Feb 14, 2011 · I would like to display a &lt;text&gt; in SVG what would auto-line-wrap to the container &lt;rect&gt; the same way as HTML text fills &lt;div&gt; elements. If you manage to hack it, that would be invalid HTML. remember the high priority (!important;) because it overrides any other unknown css rules. Normal means the text will extend the boundaries of the box. You can use the line-clamp CSS property to limit the length of a text to N lines with CSS. 1; } Change 2em to 3em to use 3 line heights (1. Apr 10, 2013 · I know you can use a combination of CSS rules to make text end with ellipsis () when it's time to overflow (get out of parent's bounds). Note: Negative values are not allowed. This is the wrapper div:. May 15, 2020 · Getting CSS to treat line-height like leading. min. If we want CSS to use a more traditional type setting style instead of the line box, we’ll want a single line of text to have no space either above or below it — but allow for multi-line elements to maintain their entire line-height value. My problem is that when this element breaks at the end of the first line and the beginning of the second line do not have padding attributes. How do I make the long words wrap ? If needed, I can use a trick with jQuery or PHP, but I would like to solve it using CSS, because it's CSS job. Jul 4, 2011 · body { /* We need a solid background or background-position: fixed */ background: #fff; /* You'll need to know the line height to clamp on line breaks */ line-height: 1. to the font-size of the parent/block element. 52. */ td. 0. line-height on text with minimum 2 lines of text. inherit Dec 9, 2016 · I have a simple layout with varying size elements that I am trying to put together for a dashboard. Text will normally warped to second line. – Jan 5, 2015 · Zero out your margin on the element, and put a display: block on it if it doesn't already have one Set your line-height for the whole block Then set a ::first-line on it, with appropriate line-height for the space you want. length: It is used to set the line height in px, pt,cm,etc. 6 - if you don't see any such parameter in the stylesheet, there's still an according browser default setting, usually between 1. Oct 11, 2013 · Not reproduceable. I want to be able to distinct between a newline \n and a wrap line resulting from text being larger than the div. It usually is defined in percent or as a multiplication factor like 1. It must have padding on each sides. Apr 21, 2015 · The CSS 3 draft specifies a hanging indent. May 15, 2020 · When a browser encounters the line-height property, what it actually does is take the line of text and place it in the middle of a “line box” which has a height matching the element’s line-height. To make the content overflow the container instead of creating a new line, use it with the nowrapvalue:. As you can see it behaves like you wanted - I'm wrapping the select box with a DIV and adding another one that will overlap the select box - he takes the select box fixed width minus the button of the select box. A rigid height will keep the div from expanding, which is what I assume you wanted. Try Teams for free Explore Teams You can set a fixed width on option elements, then use CSS text ellipsis to hide long text content, then put a title attribute on the option elements with the full text. Sep 25, 2011 · I have div with the following css style: width:335px; float:left; overflow:hidden; padding-left:5px; When I insert, into that div, a long line of text, it's breaking to a new line and displays all the text. outerHeight(); //Get the height of each line, which is set in CSS var lineheight = $('#mydiv'). Oct 11, 2015 · If you want to apply ellipsis () to a single line of text, CSS makes that somewhat easy with the text-overflow property. In your case the minimum height is equal to 22pt = 1. What I want is to have only one line of text that will not line-break. The amount of text that wraps and fills the space is greatly going to depend on your line-height, font-size and any other CSS you may have applied to the contents of the container. This is a limitation because it's not automated, and if you are applying these styles on elements with different line-heights, then you might need to reapply your line-height style. 3em). line-clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient Jul 23, 2024 · The line-height CSS property sets the height of a line box in horizontal writing modes. Apr 9, 2021 · I have a problem that I've had for years. I have tried reducing the line height to 0px but that does not help. "nowrap" will tell the browser to never wrap text, and instead to make the text continue on the line until a line break tag (<br/>) is encountered. Sep 26, 2016 · I'm trying to create a word-wrap in JavaScript using CSS, and the condition is: If DIV contains one very long word, such as "asdasfljashglajksgkjasghklajsghl", I want Feb 4, 2014 · It is essentially a standard space, the primary difference being that a browser should not break (or wrap) a line of text at the point that this occupies. text-capitalize only changes the first letter of each word, leaving the case of any other letters unaffected. it specifies a normal line height. Jan 19, 2020 · However in all my experimenting (I can't even recall all the things I've tried), the text fills up the entire line, and the divs get pushed down onto a new line. Feb 14, 2016 · No. It's still a bit tricky (due to all the requirements – see below), but text-overflow makes it possible and reliable. If you added another line of text below this you will find it 58px below this text. How to wrap the text exactly to the width of an element? Oct 13, 2021 · I try to make an input component where the text is wrapping and height of the input increases at each new line appear. g. I'm using this css: div { width: 300px; color:white; word-wrap:break-word; } My issue is with the word-wrap: Jul 18, 2009 · div { /* Set a width for element */ word-wrap: break-word } The 'word-wrap' solution only works in IE and browsers supporting CSS3. Here is a good slide show to help you understand this concept Mar 11, 2011 · AFAIK the ellipsis will appear and cut off the text at the end of the element's width. Line-height is specifically good for achieving the spacing when something wraps. Oct 12, 2012 · The simplest way is to specify the line height with a higher priority, for example you could write: line-height: 14px !important; If it is still not working set high priority in both where you u would like to decrease the line height (inline css) and also put in the body css . You can learn more about these values and how to customize them in the font-size documentation. Also, all user agents are required to support word-wrapindefinitely, for legacy reasons. inlinehelper can push wrapping text down under CSS: #responsive_wrap That depends on your definition of a single-line height, since there isn't a CSS unit that corresponds to the computed line height of an element. block { padding:10px; margin-top:10px; height:auto; background-color:#f9f9f9; } Apr 6, 2012 · I think that is better if you just use the height. , . Ask Question Asked 10 years ago. On a block container element whose content is composed of inline-level elements, 'line-height' specifies the minimal height of line boxes within the element ref. The behavior described in the text of the question depends on settings that are not included in the code, probably a very large font size, possibly overflow setting too. Such settings would well be within the scope of CSS, but there is no definition or public draft that would address such issues. Try Teams for free Explore Teams Jul 8, 2014 · If it was always one line I could just set the line-height to the container height. Setting independently. It is often set in a unitless value (e. I tried . js here because we cannot execute RAW file from github as it's content type is 'text/plain'. Feb 3, 2012 · The first 2 elements are simple divs, floated left, but the third is a little bit complicated. original text: Ultrices natoque mus m Jul 27, 2016 · The content is two lines of wrapped text with a line height of 18px (x2): 36px CSS override line-height on word wrap. See Fiddle. The line-clamp property limits the contents of a block to the specified Jul 22, 2010 · Ask questions, find answers and collaborate at work with Stack Overflow for Teams. . A nivel de elementos de bloque, define la altura mínima de las casillas encuadradas por líneas dentro del elemento. e. text-overflow: ellipsis; only works for 1 line text. CSS DIV wrapping line Dec 19, 2019 · You need to consider 3 things. Jun 19, 2015 · The CSS settings word-wrap:break-word and text-wrap:unrestricted appear to be CSS 3 features. For example, if we had this short snippet of text inside a <div> tag: The alligator went for a swim in the deep lagoon. css word wrapping alignment in a list. It is not possible to wrap text in an input as a standard feature. And I want to achieve: Apr 5, 2024 · Limit text length to N lines using CSS with max-height and line-height; Limit text length to N lines by setting the height manually # How to Limit text length to N lines using CSS. ready(function(){ //GET the total height of the element var height = $('#mydiv'). Works great, but is a major fail if that text needs to wrap. 10. // Copying Clamp. Regardless of the container's width, I May 14, 2013 · Are you sure that the line-height css property has been apply to your class? CSS. I have several divs that are all styled as inline-blocks, and therefore sit in a row next to each other. But the situation is, there may be one or two items out of 50 on a page that have a long text or a long list of owners. It won't flow over to the next line. Jul 11, 2010 · I was making a div that had a max-height of 11em and the last line of overflow text was only half there. Is there a way to do it? I don't want to Jul 7, 2015 · Ask questions, find answers and collaborate at work with Stack Overflow for Teams. 618 sans-serif; } Each font size utility also sets a default line height when one isn't provided. word-wrap: break-word; /* All browsers since IE 5. You set the line-height of that text to be equal to the height of the box. Many WYSIWYG HTML editors insert these entities in an effort to control the layout of the HTML document. It can also be set, and reset, using the text-wrap shorthand. Quickly change the font-size of text. On block-level elements in horizontal writing modes, it specifies the preferred height of line boxes within the element, and on non-replaced inline elements, it specifies the height that Specifies the space between characters in a text: line-height: Specifies the line height: text-indent: Specifies the indentation of the first line in a text-block: white-space: Specifies how to handle white-space inside an element: word-spacing: Specifies the space between words in a text In responsive web design, handling text wrapping and line breaks is key for readability across devices. In vertical writing modes, it sets the width of a line box. white-space: nowrap just eliminates that last line all together. Look at my code below to see where I placed it. I have ul max-width 200px, but when I write longer text, then my text is not visible ( now i added overflow: visible to show You what I mean ). EDIT: Jan 17, 2017 · word-wrap accepts the same values as overflow-wrap and behaves the same way. Jul 11, 2015 · I had the same problem and here is how I fixed it. Obviously I am looking for a style that can be applied to all text, and let the browser's XHTML/CSS rendering engine figure out which lines have wrapped and therefore Jul 12, 2016 · It definitely does. Mar 29, 2010 · The modern solution is to use the text-decoration-thickness property. If you want to use the golden ratio (1. ) Dec 15, 2014 · In Normalize. That's why it warped to a new line. It doesn't work the same as with images, where you'd just use float: left; for the p and float: right; for the image, in this case, h1 . Optionally the variable -line-height can also be defined higher up in the DOM hierarchy if helpful as variables are visible in all nested elements, too, until overridden. I did like the ellipsis, but I was only able to get that to work if I set white-space:no-wrap. Sep 2, 2014 · So line-height: 2em; would be double line spacing, etc. 5; } . My problem is the div that contains the dynamically generated images doesn't behave like it is housing any content - I want it to extend to the height of the list of images. 5; } Share. da-slide h2{ font-size: 36px; line-height: 36px; width: 80%; top: 40px; padding: 18px Aug 6, 2012 · Note that because 1. So don't add any, but make sure you have content: "", or it's the same as display: none. 424. Mar 11, 2021 · I'm using a line-height property and white-space: pre-line; on a raw text. The field row occupies a certain height based on the default line-height for the text size, CSS line height resizing browser text. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more. Apr 18, 2019 · $(document). CSS. Jan 10, 2012 · The line-height property is essentially setting a 29px (29 + 29 = 58) text line above and below your text, "Complete Order". By the way, it's a text which can be wrapped by the end of the line. So normal users can hover on options to see the full text, the screen reader will read the title as well. 1. clamped { overflow: hidden; position: relative; } /* Clamp to 2 lines, ie line-height x 2: Obviously any number of these classes can be written as needed */ . There are few choices you may want to try for your target: Make the inline-block div inline. 4 and 1. number: It specifies a number that is multiplied with the current font size to set the line height. hanging-indent { text-indent: 3em hanging each-line; } Unfortunately neither hanging nor each-line values are currently supported in modern browsers as the specification for CSS Text Module Level 3 is still a Draft. According to the spec, browsers “must treat word-wrap as an alternate name for the overflow-wrap property, as if it were a shorthand of overflow-wrap“. css file /* Wrappable cell * Add this class to make sure the text in a cell will wrap. I mean something like on desktop facebook. box { width: 400px; height: 100px; overflow: auto; border: 1px gold solid; } I want only a vertical scroll. 5em, then the top should be -. 2, Safari 5. Good luck finding a way to do this on current implementations. FYI: You can use either the 'normal' or 'break-word' value with the word-wrap property. Bullet points will be added to every new line/list item of your list but it will not put a bullet point when text is wrapped to the next line. Use display table or flex, to force the text and icon keeps in one line. So, if you have a line-height of 1. Aug 25, 2020 · It is possible if you rethink how you use the line-height property. Apr 19, 2013 · As it's a text element by default, the content binds to previous text, as long as there's no whitespace between them. The container of this content is fluid and will resize to the browser's width. Nov 10, 2013 · The pre tag will break the lines where there are line break characters in the text: <pre>Some text second line of text third line some longer text that will get wrapped on another line </pre> Or hide the br tags using CSS: pre br { display: none; } The text should wrap around the title (so break when it 'collides' with the title, but underneath it, it should use all the space in the div). Jul 23, 2024 · The line-height CSS property sets the height of a line box in horizontal writing modes. line-height: 1. Instead of setting the leading on a font, we get something akin to padding one either side of the line box. Use leading-<number> utilities like leading-6 and leading-7 to set the line height of an element independent of the font-size: Jul 12, 2019 · The default direction of flex is row, and when you use flex-wrap: wrap push overflowed element downed to another row, and the row height will default always equal to the highest element of that row, that why you seeing the element having that gap. By using this approach you can control text wrapping in HTML using CSS. A text with another line-height will be more readable but at the same time, it will no longer reach the top and bottom of the surrounding elements. Class {height:auto; width: 700px;} or something like that If you wrap the text in a div, give the div a height, and the text grows to be 2 lines (perhaps because it is being viewed on a small screen like a phone) then the text will overlap with the elements below it. I already tried:. My problem is not inserting ellipsis in a single text line (using the white-space: nowrap property), the main problem is that the text gets cutted in the last line, ellipsis is not an issue because in last case I can use jQuery to insert it W3Schools offers free online tutorials, references and exercises in all the major languages of the web. It’s a vital property for typographic control. Show demo Nov 5, 2024 · This guide explains the various ways in which overflowing text can be managed in CSS. I've included a snippet with the raw code and the desired result you have to add 3 css properties to li to make it: li { overflow:hidden; white-space:no-wrap; text-overflow:ellipsis; } but list-style-type will disapprear with option "overflow:hidden", and i have no idea how to get it apprear. Solution: remove the line-height from the body, or turn the span into a block (i. In my case, the text can wrap, just not exceed a certain char limit within it's container. (emphasis mine) Jan 23, 2015 · Fix custom font line-height with CSS. The title of the question is “text wrap inside a button”, but text wrapping is not mentioned at all in the question. The HTML shown below, &lt;input type="text"/&gt; is displayed in a browser like so: When I add the following text, The quick brown fox jumped over the lazy dog. The best cross browser solution is to use your server side language (php or whatever) to locate long strings and place inside them in regular intervals the html entity &#8203; This entity breaks the long words nicely, and works on all browsers. Jan 3, 2025 · The text-wrap-style CSS property controls how text inside an element is wrapped. Aug 14, 2017 · If you set the line-height to the smaller value that you want when the lines wrap and set the margin to the value that you want in between the items, you should be good to go. white-space: nowrap; and Gaby is also correct that this causes problems too. This is a default value. I'm able to get it to work with JS, but I want a pure CSS solution. Dec 12, 2011 · Line height of wrapping text in list items. Oct 25, 2024 · Using the <pre> Tag. Use the text-pretty utility to prevent orphans (a single word on its own line) at the end of a text block: Aug 18, 2011 · I'm using white-space:nowrap; to keep my text in one line. Jan 26, 2015 · The line-height property in CSS controls the space between lines of text. La propiedad CSS line-height establece la altura de una casilla remarcada por líneas. 13. On block-level elements in horizontal writing modes, it specifies the preferred height of line boxes within the element, and on non-replaced inline elements, it specifies the height that Apr 11, 2014 · Using CSS to do this will only work in Chrome You can't do it just by using CSS, but you can use some jQuery for a "look like" solution. make it a div; don't give display:block to the span). Aug 13, 2018 · I am trying to show a long text in block of div and want that if a text exceed to div height then need to show a "" otherwise fill a whole text in to a block. 1. I made the height 200px, but when I type in it the text is in the center of the textbox css; input; text; height; word-wrap; Vertically line up input fields Jan 26, 2015 · The line-height property in CSS controls the space between lines of text. By setting white-space: nowrap, the text remains on a single line without wrapping. Feb 21, 2009 · The fairly new text-wrap CSS property is currently being introduced directly for this purpose, to separate text breaking from white space collapsing. Jan 27, 2025 · Nice nice, that’s a good start. 5. If you had set the line height on the span to be greater than 200px, the line boxes would be taller, and you would see the text move further apart. The different values provide alternate ways of wrapping the content of a block element. word-wrap: break-word on li (list items)? 1. as . 2*20pt. 5em 0; line-height: 1. The best solution here would be to implement some server- or client-side script which automatically trims the text to a certain amount of characters and then appends the ellipsis. css('line-height'); //Divide The total height by line height to get the no of lines. 1em; so you use the margin to define the spacing between seperate lines Oct 24, 2024 · The overflow-wrap CSS property applies to text, setting whether the browser should insert line breaks within an otherwise unbreakable string to prevent text from overflowing its line box. But when a word is too long, a horizontal scroll is displayed. Each image is itself wrapped in a div. one-line-only { text-wrap: nowrap; } For more details, read the full documentation here: What I want to do in this case is not to show the last line, and display ellipsis in the last one. body { font: 100%/1. css, is position relative really necessary for <sup> & <sub> to fix the line-height issue? /** * Prevent `sub` and `sup` affecting `line-height` in all browsers. Jun 17, 2014 · and css:. . div { padding: 5px 5px 5px 5px; margin: 1px 1px 1px 1px; display: flex; } div. % It specifies the line height in percent of the current font. (If there is not enough text to reach the maximum width, then width: auto causes the box to shrink to fit just that amount of text. Modified 2 years, 8 months ago. I'd like the text to truncate so the blue boxes are on the same line as the text. Feb 12, 2022 · This snippet takes a 'guess' at a suitable max-height for when line-clamp is in use Limit text length to n lines using CSS. Oct 29, 2012 · Because your line-height is less and as I can see you are applying background color to your text, so increase your line-height and more over there is no unit specified, like em or px to your line-height property and btw no need of adding padding to it. Feb 21, 2020 · Yes, I am having the same result as @w3dk. fir Jun 6, 2013 · text-overflow: ellipsis only works on single line content as you need the line white-space:nowrap for it to work. You could use box-decoration-break property with value of clone. Is it possible (feel free to just say, no) to achieve th Jan 6, 2025 · The text-wrap-mode CSS property controls whether the text inside an element is wrapped. Pretty text wrapping. Dec 3, 2020 · How can I extend the vertical size of a &lt;li&gt; when text wrapping is required, but keep a minimum value? The look of this is exactly what I want when the text is short enough to fit on one lin top property on . When you click on someone, open the message box and write something in the input, the input becomes larger every new text line. horizontal list word wrap. Aug 9, 2013 · Inline elements don't honour properties such as line-height; they take on the line height of the nearest block parent. h6) apply font-size, font-weight, and line-height, these utilities only apply font-size. white-space tells the browser how to handle whitespace. May 1, 2014 · I need to fit a long text to a width of about 300 pixels. But the text is long and goes beyond the element. post-short-meta-container span { white-space: nowrap; } This doesn't move text to the next line instead it makes first div smaller in order to get free space for text and this is not desirable behavior. Comúnmente se usa para establecer la distancia entre líneas de texto. So width is 0, and height is the line For performance reasons browsers limit text balancing to blocks that are ~6 lines or less, making it best suited for headings. text-decoration-thickness: 1px; You can also change the color using the text-decoration-color property. If you know the exact line-height value for this element, then you can just explicitly set height to the same value. This is an exceptional situation—but I want it to be handled properly, and thirtydot's answer helps. Use CSS properties like `word-wrap` and `white-space` to control how text breaks within Mar 3, 2017 · When the comment is to long to fit on one line, it wraps as expected but there is too much space between the lines. The “baseline” is the imaginary line that text sits on. Using the HTML below, &lt;in Oct 2, 2020 · The reason for what you see is the line-height, which by default is relative to the font-size, i. progressStatus { height: calc(var(--line-height) * 2em); line-height: var(--line-height); --line-height: 1. So what i would do (if i understand you correctly) Give the Element where the text is inside: margin: 1. Feb 4, 2013 · Given a long string of content, I want to display just the first 2 lines of text. – Jul 12, 2011 · Heres the entire page * wrappable is defined in a main. It can also be set, and reset, using the text-wrap shorthand or the white-space shorthand. I just set a height and overflow:hidden.