tags:

views:

108

answers:

4

How can I have each of these a elements break on to new lines, but keeping them as display=inline and without br tags?

<div>
   <a href="element1">Element 1</a>
   <a href="element1">Element 2</a>
   <a href="element1">Element 3</a>
</div>
A: 

Put them in an unordered list?

Not sure I really understand what you're after here...

Andrew Heath
A: 
<style type="text/css">
  div.probablyShouldPutAClassName a {
    display: block;
  }
</style>
Ballsacian1
+1  A: 

This can be done, but will not work for all browsers. You need to use the :after pseudo-element with white-space and content. Like so

<html>
<head>
<style type="text/css">
    div a:after {white-space: pre;content:'\A';}
</style>
</head>
<body>
<div>
   <a href="element1">Element 1</a>
   <a href="element1">Element 2</a>
   <a href="element1">Element 3</a>
</div>
</body>
</html>

Reference: http://www.w3.org/TR/CSS2/generate.html#content

Jonathan
A: 

you can do this by defining equal width for the parent <div> and the <a>. assuming you apply a class 'container' to the <div>

.container { width: 100px; }
a { width: 100px; display: inline; }
pixeltocode