0

I was wondering how can align my text so it will display the way I want it to. Can someone help me display the text like it is in example 2 using CSS?

Here is what my text is doing.

Name: At vero eos et 
accusamus et iusto odio dignissimos d

Here is what I want it do.

Name: At vero eos et 
      accusamus et iusto odio dignissimos d

HTML markup.

<div><p><span>Name:</span> At vero eos et 
      accusamus et iusto odio dignissimos d</p></div>
3
  • What is the HTML markup? CSS is not a text formatting language. What you want is possible, but depends greatly on the HTML markup. Commented Jul 23, 2010 at 3:42
  • can you re-mark-up your HTML? e.g. <div class="passage"><div class="name">Name:</div><div class="dialogue">At vero eos et <br /> accusamus et iusto odio dignissimos d</div></div> Commented Jul 23, 2010 at 3:56
  • assigning classes - useful if you use div and span for other uses than name/dialogue on the page. assuming that you will only have dialogue structured like above on the page, my answer below will format all div's and span's in the same way. Commented Jul 23, 2010 at 4:08

1 Answer 1

1
<style>
div{
  font-family:"Courier New", Courier, monospace;
  margin-left: 65px;
}
span{
  margin-left: -65px;
} 
</style>

Hopefully you can put a <br /> at the end of each linebreak. If you have PHP, you can use nl2br()

You can see the results and code @ http://jsfiddle.net/Sghym/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.