0

I have written some HTML code inside PHP with echo as below:

            echo '<a class = "fragment" href = "'.$row['url'].'" target = "_blank" >';
            echo '<div>';
            echo "Title: $title"; echo '<br/>';
            echo "URL:"; echo '<h4>' .$url. '</h4>';
            echo "Preview : $preview"; echo '<br/>';
            echo "Image url: $image"; echo '<br/>';
            echo '</br>';
            echo '</div>';
            echo '</a>';

Problem is $url appears on a new line and in bold text. Though i have not used here <b> or <br/> before and after it.

How can I show it like

URL : www.url.com

same like other parameters appears?

CSS effect appears properly.

css for h4:

.fragment h4 
    {
        padding: 0;
        margin: 0;
        color: #000;
    }

    .fragment h4:hover 
    {
        background-color:#ccc;
        text-decoration: underline; 
    }
7
  • set h4 to have font-weight:normal Commented Nov 5, 2013 at 9:57
  • @Morpheus: thanks. Like text-decoration: font-weight-normal right? Commented Nov 5, 2013 at 9:58
  • 1
    Like h4 { font-weight: normal; } Commented Nov 5, 2013 at 9:59
  • 1
    @Programming_crazy it was a typo, fixed above comment Commented Nov 5, 2013 at 9:59
  • Why would you place an echo foreach HTML line? Commented Nov 5, 2013 at 10:00

1 Answer 1

6

An h4 tag is (a) a heading tag (hence the boldness) and (b) a block-level tag (hence the new line). If you don't want these aspects, why are you using it?

If you want to style this text, you should use the tag provided for the purpose: <span>. Give it a class or an id and style that.

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

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.