Jump to content

<b> overriding css in firefox


brady123

Recommended Posts

If I have the following code:

 

<b>Hello there<p>sir.</p>

 

and in my CSS the "p" tag has font-weight:normal;  the "sir" turns out bold. It seems to function correctly (making "sir" normal weight in Chrome in Explorer, but not Firefox.

 

Any ideas/fixes?

Link to comment
Share on other sites

You shouldn't have a <p> tag in the middle of <b> tags, it should be the other way around. That being said, the <strong> tag is more semantically correct that the <b> tag, and should really be used instead of the <b> tag.

Link to comment
Share on other sites

First, thanks for the tip with <strong>.

 

Second, the reason it's formatted like that is because the <b> tag came out of a MySQL entry. I'm using a SUBSTRING tag to cut off what is output after x amount of words. It happens to cut off after the <b>, and therefore leaves the rest of the page bold.

Link to comment
Share on other sites

Hmm, that still doesn't quite get what I'm going for. Perhaps if I explained myself a little better (by the way, thank you SO much for the help - I really appreciate it).

 

I'm running a query in MySQL to output questions and answers.

 

<?php
  $i=0;
  while ($i < $num and $i < 5) 
  {
  echo "<a href='/accounting-questions/index.php?qid=" . $qid . "'>$question</a><br>";
  echo "<p>$answer</p>"; 
  $i++;
  }
?>

 

In my MySQL database, the $answer field contains HTML (to format the answer how I want it to be). When I use the substring function to cut off $answer after 35 words, I am sometimes left in the middle of a bolded statement (for example: "you <strong>need to" where it cuts off before I include </strong> to end the statement).

 

THEN, on my next loop, the $question and $answer variables are bolded because that <strong> tag never was closed, since the substring only grabbed the first 35 words - before the tag was closed.

 

In my <p> tag, on my style sheet, I have font-weight:normal;    This seems to revert the text back to normal in Chrome and Explorer, but not Firefox. Firefox keeps the <strong> attribute from the first instance.

 

Does this make sense? I'm still fairly new to PHP and MySQL databases, so perhaps there is a better way. Thanks!

Link to comment
Share on other sites

The problem with strip tags is that I WANT to keep my html/php tags in the output. It's just that the <strong> tag is overriding the font-weight:normal; style tag, even though the font-weight:normal tag comes after the <strong> tag.

 

Does that make sense?

Link to comment
Share on other sites

Then you go to the other suggestion I made:

 

$answer = str_replace('<strong>', '', $answer);
$answer = str_replace('</strong>', '', $answer);

 

This will remove any strong tags, both opening and closing (this works for the situation where the closing tag also exists in the text.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.