Forum Moderators: not2easy

Message Too Old, No Replies

Inserting a link in from stylesheet

CSS link embedding

         

Imanamateur

6:04 pm on Oct 27, 2007 (gmt 0)

10+ Year Member



I'm a newbie, my first posting and only have rudimentary knowledge of CSS. I understand the principles I think, it's those picky little details....
Ok my question:
I would like to embed links in my divs from the external CSS without scripting. Is this possible?

penders

8:01 pm on Oct 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



CSS is for presentation not behaviour. So embedding links is not possible with CSS. Any link is best done with plain ol' HTML.

You could, however, make certain links visible/invisible using CSS by applying different classes to your links - but they would first need to be marked up in the HTML. Is that what you require?

...welcome to WebmasterWorld! :)

Imanamateur

8:33 pm on Oct 27, 2007 (gmt 0)

10+ Year Member



Thanks, sometimes it's hard to know what is possible or not. I just want to add a link to all my pages and looks like I have to do just that. Oh well, worth a try.

penders

12:28 pm on Oct 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I just want to add a link to all my pages and looks like I have to do just that.

You could use JavaScript (although you mention 'without scripting'), but the link wouldn't be spiderable by search engines nor available to those without scripting enabled. Or use server-side scripting such as PHP to add common elements to your pages. The end result is an HTML link on the page. Either way you'd still probably have to go through and modify every page anyway in the first instance.

Imanamateur

3:02 pm on Oct 28, 2007 (gmt 0)

10+ Year Member



Thanks again for your comments. I will probably eventually put php templates and all that but, it will take me a while to learn it. I live in Mexico so it's difficult for me to get reference materials so I have to learn some things by trial and error so I thought I would try posting. I do have good books on perl cgi javascript html but nothing for php so I'm learning it by looking at the files on my downloaded wordpress blog site. It makes my brain hurt trying to trace the styles and php stuff through to even make small changes. Blah blah blah. You'll probably see me eventually asking questions about php stuff. btw I already put the html links in my pages. It was really not so hard, I more am trying to plan for easier revisions in future by putting as much as I can in the style sheets.

[edited by: Imanamateur at 3:04 pm (utc) on Oct. 28, 2007]

penders

7:55 pm on Oct 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Best of luck with the learning process... I think we're all still learning! I've just realised myself that I don't actually have a book on CSS - but there are some great resources to be found online. These forums for instance!

As for PHP (and other) you could have a look here...
[w3schools.com...]

Imanamateur

4:20 am on Oct 29, 2007 (gmt 0)

10+ Year Member



Thanks again, I'll go have a look.

Marcia

12:58 pm on Oct 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't have to know PHP to use includes, it's very easy. You just put the HTML for the links in a text file called navigation.php.

Very simplified, substitute your own navigation code:

<p align="center">
<a class="nav" href="http://www.example.com">Home</a> ¦
<a class="nav" href="http://www.example.com/page2.html">Page 2</a> ¦
<a class="nav" href="http://www.example.com/page3.html">Page 3</a>
</p>

That will be what's in navigation.php file. Then you "call" the include where you want the navigation to appear on the pages instead of the code on the page now. Like this:

<?php include ("includes/navigation.php");?>