How to give a line break using CSS?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tess1243
    New Member
    • Jun 2010
    • 20

    How to give a line break using CSS?

    How to give a line break using CSS?

    Is this possible?
  • londres9b
    New Member
    • Apr 2010
    • 106

    #2
    Well, technically it's not possible. I mean, you can't insert an html element in a CSS style.

    If you have this:

    Code:
    <div class="topic">This the 1st Topic</div>
    <div class="topictext">The 1st Topic is all about...</div>
    You'll notice that there is already a line break. That's because we ended a div and began another.


    But if you have this:

    Code:
    <div class="topic">This the 1st Topic<span class="newline">Another line...</span></div>
    There's no line break there!

    So you could set display:block to the span and it will create a line break.
    Code:
    .newline {
     display:block;
    }
    But..Why don't you just use <br /> ? It's valid XHTML if it's about that.

    Comment

    • tess1243
      New Member
      • Jun 2010
      • 20

      #3
      Thank You londres9b.

      display:block; solved my issue. :) :D

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        CSS3 has word-wrap:break-word which works in all browsers and is a better idea.

        Comment

        Working...