List output

I need to output a listing of activities, which should be grouped by category. Right now I use an unsorted list. Which example you can see here:

Listing Example

The way it is now it looks quite okay, but in each category there could be more than one activity (There could be for example 5 different walks) Where I’m now struggling with is how I create space between the different activities within a group? This is what i have in the page:


<div class="content">

<cfoutput query="getListing" group="category_name">
<ul class="listing">
<h2><img src="category_icons/#category_icon#" />#category_name#</h2>
<cfoutput>
<li>Name: <span>#activity_name#</span></li>
<li>Title: <span>#activity_title#</span></li>
</cfoutput>
</ul>
</cfoutput>

</div> 

Sorry for the server side scripting included, but that is also to indicate that the content is created dynamically and could change over night.

You’ve got a <h2> inside the <ul>, that doesn’t validate. Put it before the <ul>.

To list more activities, you could use a separate <ul> for each activity, and create some space between them using CSS.

As Guido said that h2 is in the wrong place as nothing can come in that dead space between the ul and the opening list tag.

I would make that structure one list anyway and not multiple lists.

e.g.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.listing {
    width: 516px;
    margin: 0 17px;
    float: left;
    display:inline;
}
.listing h2 {
    margin:0 0 10px;
    padding: 5px 0;
    font-size: 1.5em;
    color: #304a07;
}
.listing h2 img {
    width: 40px;
    height: 40px;
    float: left;
    margin-left:-80px;
}
.listing p {
    margin:0
}
.listing li {
    width: 100%;
    float: left;
    padding-left: 80px;
    color: #86bd03;
    list-style: none;
    margin:0 0 20px;
}
.content .listing li span {
    display: inline-block;
    color: #1d6406
}
</style>
</head>
<body>
<ul class="listing">
    <li>
        <h2><img src="http://acthol.bgmultimediaserver.net/category_icons/walking.jpg" alt="" />&#928;&#949;&#950;&#959;&#960;&#959;&#961;&#943;&#945;</h2>
        <p>Name: <span>&#924;&#965;&#954;&#942;&#957;&#949;&#962; &#957;&#945; Prosymna</span></p>
        <p>Title: <span>&#931;&#964;&#945; &#946;&#942;&#956;&#945;&#964;&#945; &#964;&#959;&#965; &#913;&#947;&#945;&#956;&#941;&#956;&#957;&#959;&#957;&#945; - &#928;&#949;&#961;&#943;&#960;&#945;&#964;&#959;&#962; &#963;&#964;&#951;&#957; &#913;&#961;&#967;&#945;&#943;&#945; &#916;&#961;&#972;&#956;&#959;&#953; &#924;&#965;&#954;&#951;&#957;&#945;&#970;&#954;&#942;</span></p>
    </li>
    <li>
        <h2><img src="http://acthol.bgmultimediaserver.net/category_icons/cooking.jpg" alt="" />&#924;&#945;&#947;&#949;&#953;&#961;&#953;&#954;&#942;</h2>
        <p>Name: <span></span></p>
        <p>Title: <span>&#928;&#945;&#961;&#945;&#948;&#959;&#963;&#953;&#945;&#954;&#942; &#917;&#955;&#955;&#951;&#957;&#953;&#954;&#942; &#924;&#945;&#947;&#949;&#953;&#961;&#953;&#954;&#942;</span></p>
    </li>
    <li>
        <h2><img src="http://acthol.bgmultimediaserver.net/category_icons/horsriding.jpg" alt="" />&#921;&#960;&#960;&#945;&#963;&#943;&#945;</h2>
        <p>Name: <span></span></p>
        <p>Title: <span>&#921;&#960;&#960;&#945;&#963;&#943;&#945; &#963;&#964;&#951;&#957; &#913;&#961;&#954;&#945;&#948;&#953;&#954;&#942; &#949;&#958;&#959;&#967;&#942;</span></p>
    </li>
</ul>
</body>
</html>


Great example Paul, that works great thanks a lot!

Hi Paul, one last question regarding this! Like I said. It works great, but in a few case the text within the <span> is quite long and in such cases the entire <span> wraps to the next line, aligning left with the word Title:. I.E.


Title: 
This is what is happening when the text within the span is longer than the
available width.

Is there somehow a way, that when the text is to long, it still start next to the word title but that the exceeding text goes to the next line, starting under the beginning of the <span> text, I.E.


Title: This is span from which the text is longer than the
       available width.

Thank you in advance.

You could do this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.listing {
    width: 516px;
    margin: 0 17px;
    float: left;
    display:inline;
}
.listing h2 {
    margin:0 0 10px;
    padding: 5px 0;
    font-size: 1.5em;
    color: #304a07;
}
.listing h2 img {
    width: 40px;
    height: 40px;
    float: left;
    margin-left:-80px;
}
.listing p {
    margin:0;
        padding:0 0 0 4em;
}
.listing p b{
    width:3.5em;
    margin-left:-4em;
    float:left;
    clear:left;
}
.listing li {
    width: 100%;
    float: left;
    padding-left: 80px;
    color: #86bd03;
    list-style: none;
    margin:0 0 20px;
}
.content .listing li span {
    display: inline-block;
    color: #1d6406
}

</style>
</head>
<body>
<ul class="listing">
    <li>
        <h2><img src="http://acthol.bgmultimediaserver.net/category_icons/walking.jpg" alt="" />&#928;&#949;&#950;&#959;&#960;&#959;&#961;&#943;&#945;</h2>
        <p><b>Name:</b> <span>&#924;&#965;&#954;&#942;&#957;&#949;&#962; &#957;&#945; Prosymna</span></p>
        <p><b>Title:</b> <span>&#931;&#964;&#945; &#946;&#942;&#956;&#945;&#964;&#945; &#964;&#959;&#965; &#913;&#947;&#945;&#956;&#941;&#956;&#957;&#959;&#957;&#945; - &#928;&#949;&#961;&#943;&#960;&#945;&#964;&#959;&#962; &#963;&#964;&#951;&#957; &#913;&#961;&#967;&#945;&#943;&#945; &#916;&#961;&#972;&#956;&#959;&#953; &#924;&#965;&#954;&#951;&#957;&#945;&#970;&#954;&#942;</span></p>
    </li>
    <li>
        <h2><img src="http://acthol.bgmultimediaserver.net/category_icons/cooking.jpg" alt="" />&#924;&#945;&#947;&#949;&#953;&#961;&#953;&#954;&#942;</h2>
        <p><b>Name:</b> <span></span></p>
        <p><b>Title:</b> <span>&#928;&#945;&#961;&#945;&#948;&#959;&#963;&#953;&#945;&#954;&#942; &#917;&#955;&#955;&#951;&#957;&#953;&#954;&#942; &#924;&#945;&#947;&#949;&#953;&#961;&#953;&#954;&#942;</span></p>
    </li>
    <li>
        <h2><img src="http://acthol.bgmultimediaserver.net/category_icons/horsriding.jpg" alt="" />&#921;&#960;&#960;&#945;&#963;&#943;&#945;</h2>
        <p><b>Name:</b> <span></span></p>
        <p><b>Title:</b> <span>&#921;&#960;&#960;&#945;&#963;&#943;&#945; &#963;&#964;&#951;&#957; &#913;&#961;&#954;&#945;&#948;&#953;&#954;&#942; &#949;&#958;&#959;&#967;&#942;</span></p>
    </li>
</ul>
</body>
</html>

Works great as usual. Thanks a lot.