<b> or <STRONG> tag missbehave in CSS page

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
www.in.no
Forum Newbie
Posts: 4
Joined: Wed Jul 27, 2005 7:36 am

<b> or <STRONG> tag missbehave in CSS page

Post by www.in.no »

Hi, i am new to CSS and have start learning by using "Copy and Past" and reading online tutorials and documents.

I am trying to put a <b> tag inside a content section of a page to put weight to some choosen words.
But when using the <B> tag it starts on a new line, <STRONG> is working.

What is the main different between the 2 tags, and what to use regarding SEO. I was told that the searchengin favor the <B> tag and i also se some SEO test pages recomend using <B> tag.

Any suggestions on how to solve thees problems.

Here is the source code for the content:
(And the temp place for the page is http://develop.in.no)

Code: Select all

<div class="content">
<div><div>
  <p>
</p>
  <p>&nbsp;    </p>
  <h3>ADSL.in.no - Din portal for bredband. </h3>
    <p> ADSL.in.no har som mål å være en uavhengig portal som gir deg hjelp med dine bredbåndsvalg ut i fra ditt behov og ønsker.</p>
    <p>Trenden fremover viser at det blir st&oslash;rre kamp om b&aring;ndbredden og det gir h&oslash;yere hastigheter til forbrukerne.<br>
      IP telefoni begynner &aring; ta av og vi ser en stor vekst i dette markede. <b>ADSL</b> </p>
    <p /> 
    <p />
<hr></div></div>
</div>
<!-- Content slutter her -->
And the content in CSS:

Code: Select all

.content { 
  float: left;
  width:28em;
  margin:0px 5px 10px 5px;
  background-color:#f4f4f4;
  color: #476D84;
  padding:2px 10px 10px 10px;
  z-index: 4;
  border-left: 1px dotted #FAA004;
}
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

I had a look at your full stylesheet and you have explicitly defined attributes for a <b> occuring within the .content div:

Code: Select all

.content b{ 
z-index: 4;
  background-color:#f4f4f4;
  color: #476D84;
}
That's fine, but I am intrigued as to why you have given it a z-index. Try removing that. Maybe this is making the <b> tag behave as a block level element instead of an inline element. I don't think so, but I can't see why you would need a z-index here anyway.

[edit] Actually I think it posiibly has more to do with the <b> tag inheriting the float: left attribute of the content class. Play around with that a bit [/edit]
www.in.no
Forum Newbie
Posts: 4
Joined: Wed Jul 27, 2005 7:36 am

Post by www.in.no »

As I wrote in my post, just learning by copy and past so I have not figure out on all the properties yet..... But I will try to remove it in both the b section and the content.
defined attributes for a <b>.
That was just a try, have the same behaviour with or without this...
www.in.no
Forum Newbie
Posts: 4
Joined: Wed Jul 27, 2005 7:36 am

Post by www.in.no »

Just tried locally to remove Z index and no change...

It seem that the B tag inherit some properties, if I remove the attribute for b tag the text become invisible.

[edit] Actually I think it posiibly has more to do with the <b> tag inheriting the float: left attribute of the content class. Play around with that a bit [/edit]
[edit] I tryed locally to remove the hole flot properties and no big changes.[/edit]
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

stick this in the properties for .content b{ ....}

Code: Select all

display: inline;
and it will fix it. Ideally you should find out where it is inheriting the property from that is causing it to either float or display as a block. I tried messing about with the content class but that didn't seem to have an effect.

The fix above should sort your problem out tho. :)
www.in.no
Forum Newbie
Posts: 4
Joined: Wed Jul 27, 2005 7:36 am

Post by www.in.no »

Thanks, :D That fixed it for now...Then i can look for the inherited rights later...

Do you have any comments regarding the use of B or STRONG regarding SEO
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

Regarding SEO I don't know, but at the risk of making my above posts useless I would say that it is better practice to use <strong> rather than <b> for accessibility and semantic reasons.

However I do find this a bit of a pain to implement, and would much rather quickly type a <b> tag than <strong> anyday. You can still get away with either and your page will still validate in HTML or XHTML .... for now.
Post Reply