-2

preview of website homepage

my first problem is that the link wont work for li b

is this something impossible?

I want to move the navbuttons down to align with the logo. Also, I want to change the logo img for every navbutton (see img)

<ul>

  <li><a href="home"><img src='images/logo1.jpg' width='550 height='400' onmouseover="this.src='images/logo.jpg';" onmouseout="this.src='images/logo1.jpg';" /></a></li>
  <li><b href="music"><img src='images/m.jpg'/></b></li>
  <li><b href="news"><img src='images/j.jpg'/></b></li>
  <li><b href="contact"><img src="images/s.jpg"/></b></li>
  <li><b href="about"><img src="images/g.jpg"/></b></li>
  <li><b href="contact"><img src="images/p.jpg"/></b></li>
  <li><b href="about"><img src="images/c.jpg"/></b></li>
</ul>


ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;}
li {
    float: left;}

li a {
    display: block;
    padding: 0px 0px;
    text-decoration: none;}

li b {
    display: block;
    padding: 280px 0px 0px 0px ;
    text-decoration: none;}

li b:hover{

Hope someone can help, though i am really noob still

  • 4
    No... `b` does not understand `href` attribute. Just make it separate: `xxx`. For details, read the online HTML documentation at http://www.w3.org. – lurker Aug 22 '16 at 14:21
  • There you can see the attributes that B can have: http://www.w3schools.com/tags/tag_b.asp – Sergio Tx Aug 22 '16 at 14:23
  • Thank you, that works, ofcourse. been going at it for a while and guess i mixed stuff up. – Ben Brugman Aug 22 '16 at 14:31

2 Answers2

2

href is what's known as an "attribute". Elements (like <a> and <b>) define and support their own attributes, so you can't just use an attribute that "works" with one element and use it on another. That said, some attributes, like class, have nearly universal support (meaning they are supported by almost all elements).

The short answer to your question is "no"... the <b> element does not support the href attribute.

You can, however, wrap most elements in an <a> tag to turn it into a link, like so:

<a href="http://www.google.com"><b>Go To Google</b></a>

Note that the href attribute must be a URL or URI if you want the link to actually work. home is not a URL, and thus the link won't work as you'd expect. See MDN's "What is a URL?" for more information.

For future reference, check out MDN's HTML element reference. There, you will find a complete list of elements and the attributes they support.

JDB
  • 25,172
  • 5
  • 72
  • 123
  • Thank you for your reply and i will look into that. – Ben Brugman Aug 22 '16 at 14:31
  • I'd recommend you avoid w3.org. A lot of their tutorials are buggy and the documentation is incomplete or outright incorrect. [MDN (Mozilla Developer Network)](https://developer.mozilla.org/) is much more thorough and is generally easier to understand (especially for beginners). – JDB Aug 22 '16 at 14:33
0

No you cannot use href with b.

As per the mdn reference: https://developer.mozilla.org/en/docs/Web/HTML/Element/b

which says standard attributes only, which are stated here: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes

I would suggest converting all your b tags to a. If you want to style them to look like b, you can do so using css.

Using the right html element for designed purpose is a best practice.

Please see What are the benefits of using semantic HTML?

Community
  • 1
  • 1
Arathi Sreekumar
  • 2,544
  • 1
  • 17
  • 28