1

i have div with 500px width which contains multiple anchors... problem anchors not wrapping in to multiple lines.... i tried using table as well same problem....

<div  style="width:500px;">
    <a href="#procrit">procrit</a>&nbsp;
    <a href="#doxil">doxil</a>&nbsp;
    <a href="#prezista">prezista</a>&nbsp;
    <a href="#simponi">simponi</a>&nbsp;
    <a href="#reopro">reopro</a>&nbsp;
    <a href="#topamax">topamax</a>&nbsp;
    <a href="#invega">invega</a>&nbsp;
    <a href="#axert">axert</a>&nbsp;
    <a href="#aciphex">aciphex</a>&nbsp;
    <a href="#concerta">concerta</a>&nbsp;
    <a href="#risperdal">risperdal</a>&nbsp;
    <a href="#remicade">remicade</a>&nbsp;
    <a href="#velcade">velcade</a>&nbsp;
    <a href="#doxil">doxil</a>&nbsp;
    <a href="#regranex">regranex</a>&nbsp;
    <a href="#nucynta">nucynta</a>&nbsp;
    <a href="#duragesic">duragesic</a>&nbsp;
    <a href="#leustatin">leustatin</a>&nbsp;
    <a href="#invega">invega</a>&nbsp;
    <a href="#sustenna">sustenna</a>&nbsp;
    <a href="#reminyl">reminyl</a>&nbsp;
    <a href="#natrecor">natrecor</a>&nbsp;
</div>
4
  • You need to format your HTML as code by indenting it with four spaces. You will then be able to use <a> tags. Also, please add newlines. Commented Nov 3, 2010 at 2:37
  • i don't want every anchor in new line... after exceeding specified width it must come in the next row... Commented Nov 3, 2010 at 2:38
  • 1
    You should add newlines to your code so that people can read it. Commented Nov 3, 2010 at 2:45
  • edited for readability - acknowledged that it should be single line for purposes stated Commented Nov 3, 2010 at 3:13

3 Answers 3

6

Try replacing &nbsp; with just a space character. &nbsp; prevents the browser from wrapping words it is attached to. Each <a> will not appear on a new line, but it will successfully wrap if it no longer fits its container if using normal spaces.

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

Comments

1

If there is no white-space between the anchors, it is considered all one string and therefore can not wrap. You could try to use the CSS rule word-wrap to help with this, but some browsers may not honor such a setting.

Simple solution is to change &nbsp; to an actual spaces. Or use a <ul> and have the <li> display: inline;. The latter is arguably more semantic.

2 Comments

that's the reason i added &nbsp;
&nbsp; is a non-breaking space and therefore still doesn't break.
0

Use float:left;margin-right:5px

&nbsp; is a naughty way to force spacing; you'll get much more consistent and professional results with good CSS (in this case, margin).

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.