Search code examples
htmlhtml-heading

Put a H3 tag into A or LI tag


With the code below, I generate a tree menu from sql results. I want to put the <a> text into a <h3> tag.

Whats the right and valid way for that?

foreach($res AS $t)
{
    if($oldal_most == "kategoria")
    {
        if($seocim == $t["kat_id"])
        {
            $style = 'class="kategoria_now"';
        }
        else
        {
            $style = 'class="kategoria_simple"';
        }
    }
    echo '<li id="kategoria_'.$t["kat_seo_url"]."-".$t["kat_id"].'"><a href="'.$host."".str_replace('//','/',"/kategoria/".$t["kat_id"]."/".$pre."/". $t["kat_seo_url"]).'" '.$style.' title="'. $t["kat_nev"] .'">'. $t["kat_nev"] .'</a>';
    if($t["subcatsnumber"] > 0 AND isset( $_GET["q"]) AND (in_array($t["kat_seo_url"] , $this->modules)) )
    {
        echo '<ul>';
        $this->renderKatLi($t["kat_id"] , str_replace('//','/',  $pre."/".$t["kat_seo_url"] ), $level++  );
        echo '</ul>';
    }
    echo '</li>';
}

Solution

  • Could you do this:

    <h3><a href="'.$host."".str_replace('//','/',"/kategoria/".$t["kat_id"]."/".$pre."/". $t["kat_seo_url"]).'" '.$style.' title="'. $t["kat_nev"] .'">'. $t["kat_nev"] .'</a></h3>'
    

    Or this:

    <a href="'.$host."".str_replace('//','/',"/kategoria/".$t["kat_id"]."/".$pre."/". $t["kat_seo_url"]).'" '.$style.' title="'. $t["kat_nev"] .'"><h3>'. $t["kat_nev"] .'</h3></a>