brady123 Posted July 14, 2010 Share Posted July 14, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/ Share on other sites More sharing options...
haku Posted July 14, 2010 Share Posted July 14, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/#findComment-1085944 Share on other sites More sharing options...
brady123 Posted July 14, 2010 Author Share Posted July 14, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/#findComment-1085947 Share on other sites More sharing options...
haku Posted July 15, 2010 Share Posted July 15, 2010 In that case, if you are running php (which it sounds like it since you are using substring), you should run strip_tags() on the output to remove the any html tags. Either that or use a str_replace() to remove that tag specifically. Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/#findComment-1086196 Share on other sites More sharing options...
brady123 Posted July 15, 2010 Author Share Posted July 15, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/#findComment-1086757 Share on other sites More sharing options...
haku Posted July 16, 2010 Share Posted July 16, 2010 As I mentioned, run $answer through strip_tags(). This will strip out any HTML tags, and you won't be left with any un-closed tags. Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/#findComment-1086828 Share on other sites More sharing options...
brady123 Posted July 16, 2010 Author Share Posted July 16, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/#findComment-1087176 Share on other sites More sharing options...
haku Posted July 17, 2010 Share Posted July 17, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207730-overriding-css-in-firefox/#findComment-1087323 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.