Click here to Skip to main content
15,886,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to write some html with results that should look like this

VB
Apples       X
Pears        Y
Strawberries Z


using the following code:
XML
<html>
<head>
<style type="text/css">
.test {dislay:inline;}
</style>
</head>
<body>


<ul>
<li><div class='test'><div style='width:500px;'>Apples</div>X</div></li>
<li><div style='width:500px;'>Pears</div>Y</li>
<li><div style='width:500px;'>Strawberries</div>Z</li>
</ul>
</body>
</html>


I can't seem to create the alignment of the last character.

Any help would be welcomed.
Posted
Comments
Richard C Bishop 21-Apr-14 12:56pm    
You could use a table to format that. It would be easier than unordered lists and div combination.
csugden 21-Apr-14 13:40pm    
Yes I could use another approach but to improve my knowledge of html I would like to know how to accomplish this within a list.

1 solution

XML
<style type="text/css">
.test li span
{
    width: 500px;
}

.firstSpan
{
    float: left;
}

.test
{
    list-style-type: none;
}
</style>
<ul class="test">
<li>
    <span class="firstSpan">Apples</span>
    <span>X</span>
</li>
<li>
    <span class="firstSpan">Pears</span>
    <span>Y</span>
</li>
<li>
    <span class="firstSpan">Strawberries</span>
    <span>Z</span>
</li>
</ul>
 
Share this answer
 
v2
Comments
csugden 21-Apr-14 13:40pm    
Yes I could use another approach but to improve my knowledge of html I would like to know how to accomplish this within a list.
Guruprasad.K.Basavaraju 21-Apr-14 14:05pm    
Check the updated Solution
csugden 21-Apr-14 15:10pm    
I am running IE 8. it seems like the second span tag on the X, Y and Z was not necessary.
I removed them and the solution appeared.

Thanks
Guruprasad.K.Basavaraju 21-Apr-14 15:19pm    
Great, if have the third element then you need the second span else you are right its not necessary.

Also please close this question by accepting the answer.
csugden 21-Apr-14 16:08pm    
Done

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900