-2

I have a div within which I put paragraphs of text, images, links etc., I am unable to use the line height property. I retrieve this content from my database using PHP.

A typical scenario would be,

<div class = "story">
Now there are many complaints. We will study the matter... Whether there is a need for a separate policy or some kind of clarification is needed, we will make it clear soon

Now there are many complaints. We will study the matter... Whether there is a need for a separate policy or some kind of clarification is needed, we will make it clear soon
</div>

.story{
   line-height: 200px;
}

I type in the content into a and it is stored in a db. Now I observe that where ever I physically ended my line by pressing enter I get a gap of 200 px. Not between the lines. Based on the screen resolution and other things a line could end anywhere right?

however it is working something like this,

enter image description here

Edit 1: Yes I have tried word-wrap: break-word it doesn't work.

Aditya
  • 1,240
  • 2
  • 14
  • 38
  • 1
    Didn't understand the question, but you can always use the width property to limit the width of the div element. Also it should be
    not .
    – albusshin Oct 08 '14 at 13:31
  • 3
    Your question makes no sense. – GolezTrol Oct 08 '14 at 13:32
  • Is this because you are using `line-height` to vertically position your block of text? If so, you are addressing the wrong issue. – George Oct 08 '14 at 13:32
  • Sentence breaks are usually accomplished with the `
    ` tag. Your title refers to breaking a sentence, yet your question itself makes little sense.
    – j08691 Oct 08 '14 at 13:32
  • possible duplicate of [How to force a line break in a loooooong word in a DIV?](http://stackoverflow.com/questions/3058866/how-to-force-a-line-break-in-a-loooooong-word-in-a-div) – Gildas.Tambo Oct 08 '14 at 13:38
  • You should also use proper text tags instead of bare text nodes (as shown) and not use break tags for spacing. That's what margin/padding is for. – Paulie_D Oct 08 '14 at 14:00
  • I don't use break tags for spacing. I have a – Aditya Oct 08 '14 at 14:03

2 Answers2

1

You can use this if you want to break the sentence and then line-height might work

 .story{
 word-wrap: break-word;
} 
Akshay
  • 14,138
  • 5
  • 46
  • 70
0

The line isn't breaking because you're using the wrong tag i.e. </br>. You need to use a <br/> tag to add a line break: DEMO

HTML:

<div class = "story">
    Now there are many complaints. We will<br/> study the matter... Whether there is a need for a<br/> separate policy or some kind of clarification is needed,<br/> we will make it clear soon 
</div>
Fahad Hasan
  • 10,231
  • 4
  • 29
  • 36