href in css
# March 14, 2010 at 11:16 pm
Does anyone know of a way to use a href in css, the way you can use background and pass it a graphic with href? I want to have an cascading menu with graphics, which are being passed in from css. What should happen is when the user click a menu item it should take you to a page, but since there is no text in the html, (see below) where i’ve put "text should go here", it doesn’t work, if i put so much as a period there it will work, but this is not a viable solution.
Eg.,"This is a snippet of the css"
background: url(../images/contactusbutton.jpg) left center no-repeat;
Eg., "This is a snippet of the html"
<ul id="MenuBar1" class="MenuBarVertical">
<li id = "home">"text should go here"<a href="index.php">
<li id = "aboutuswithout" >
<a href="aboutus.php" class="MenuBarItemSubmenu"></a>
<li id = "serviceswithout"># March 15, 2010 at 7:42 am
If you want to target an anchor you just use "a"
Noah is right – if there is no content inside the link then there will be no width – this is because it is classed as an inline element by default.
You can make it a block element and give it a width and height by using display:block when styling it. If you want it to still behave inline but be a block you need to use "display:inline-block" … in earlier version of IE you will need to use a float to make it stay inline.
So you need something like this…
that will force a width and height of the anchor.
You must be logged in to reply to this topic.