Can't format links on page.

Discussion in 'CSS' started by RobinInTexas, Oct 29, 2013.

  1. #1
    Trying to format links on FAQ page and cannot get the format to work at all.

    The javescript text popout is working fine.

    Here's a snippet of the code:

    <script language="javascript" type="text/javascript">
    function over(faqup) {
     
        document.getElementById(faqup.id).style.display = "block";
        }
    function out(faqup) {
        document.getElementById(faqup.id).style.display = "none";
        }
    
    </script>
    <style type="text/css">
    p {margin-left:20px;}
    a.ques:link {font-weight:bold; font-size:17pt; font-family: arial,helvetica,tahoma,sans-serif; color:steelblue; text-decoration:none;}
    a.ques:visited {font-weight:bold; font-size:17pt; font-family: arial,helvetica,tahoma,sans-serif; color:steelblue; text-decoration:none;}
    a.ques:hover {font-weight:bold; font-size:17pt; font-family: arial,helvetica,tahoma,sans-serif; color:steelblue; text-decoration:none;}
    p.ques {font: bold 17pt arial,helvetica,tahoma,sans-serif;color: steelblue; text-decoration:none;}
    </style>
    </head>
    <body>
    <h3>F.A.Q.</h3>
    
    <div id="ques"><p><a href="#" onmouseover="over(ans1)" onmouseout="out(ans1)">This is the first of the FAQ's</a></p></div>
    <div id="ans1" style="display:none;">
    <p> Culpa tail consectetur pork venison beef. Tail leberkas nostrud, jerky pancetta enim laboris prosciutto turkey pariatur cillum frankfurter sed pastrami. Fatback bacon bresaola chuck quis nostrud et consectetur hamburger commodo reprehenderit qui pariatur pig ribeye. Minim jowl consequat in strip steak.</p>
    </div>
    
    HTML:
    I've tried several things, and can't alter the text properties within the link. I want to remove the underline and set the font color and make the type bold.

    here's a link to the complete test page code

    http://pastebin.com/WPjJ6Rka
     
    RobinInTexas, Oct 29, 2013 IP
  2. wiicker95

    wiicker95 Well-Known Member

    Messages:
    438
    Likes Received:
    37
    Best Answers:
    10
    Trophy Points:
    100
    #2
    We've got a nasty case of misuse of JavaScript here. Aside the fact that is ridiculously sloppily written, a thing I point out almost every time, there's just no reason to even use js here. I should also mention that many people browse with JS off, so they don't even get to see what's behind the hover (ever heard of graceful degradation?).

    I'll post you a working snippet by tomorrow, I promise.

    A fun fact about this nonsense, btw: With 3kb of markup, you deliver 75 bytes of (questionably) usable data.
     
    wiicker95, Oct 29, 2013 IP
  3. RobinInTexas

    RobinInTexas Active Member

    Messages:
    217
    Likes Received:
    14
    Best Answers:
    2
    Trophy Points:
    65
    #3
    I just tried to use some js I found on the web. I'd prefer to do it using css.
     
    RobinInTexas, Oct 30, 2013 IP
  4. Bogdanel

    Bogdanel Active Member

    Messages:
    77
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    65
    #4
    you select there a.ques and a hasn't class ques. to select that a you can use #ques a which means you will select any a in div with ID ques, or you can simply add the class ques to the a. :)
     
    Bogdanel, Nov 1, 2013 IP
    ryan_uk likes this.
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Bogdanel has it right -- you are attempting to target a class that doesn't exist... Though as wiicker95 implied I'd be left asking what the devil makes that an anchor since it doesn't actually link to anything, what the devil makes that anchor a paragraph, why you need so many DIV, why you are using javascript to do CSS' job... Basically that whole mess needs to be pitched in the trash.

    I'm also a little surprised that 'FAQ' would make it all the way down to a H3... but I'd have to see the rest of the page to be sure on that; are you sure that on the real page it would be a subsection of the h2 preceding it, which in turn is a subsection of the h1 preceding it, or are you just choosing headings based on their appearance?

    The CSS is also pointless crap -- since anything you set on an A should inherit to all it's psuedostates, condensed font properties would shorten it, crapping everything on one line is hard to read, PT (points) is for print not screen, and since arial and tahoma are part of the same core Microsoft font set there is no reason tahoma would EVER be used in your font stack. (particularly with arial predating tahoma)... and of course setting display:none as the default state can make search engines and screen readers ignore that text. (one of the few bits of CSS browser aids like JAWS will obey!)

    Assuming that should indeed be a h3:
    <h3><abbr title="Frequently Asked Questions">FAQs</abbr></h3>
    
    <div class="question">
    	<h4>This is the first of the FAQ's</h4>
    	<div class="content">
    		<p>
    			Culpa tail consectetur pork venison beef. Tail leberkas nostrud, jerky pancetta enim laboris prosciutto turkey pariatur cillum frankfurter sed pastrami. Fatback bacon bresaola chuck quis nostrud et consectetur hamburger commodo reprehenderit qui pariatur pig ribeye. Minim jowl consequat in strip steak.
    		</p>
    	<!-- .content --></div>
    <!-- .question --></div>
    Code (markup):
    with this for CSS:
    /* use aPo instead of display so screen readers still read it! */
    
    .question .content {
    	position:absolute;
    	left:-999em;
    }
    
    .question:hover .content {
    	position:relative;
    	left:0;
    }
    
    .question h4 {
    	text-decoration:none;
    	font:bold 125%/120% arial,helvetica,sans-serif;
    	color:#48B;
    }
    Code (markup):
    The aPo removes it from flow, we then slide it out of the way so it can't be seen. On hover of it's parent (and therein the h4 AND .content) we remove the left position and set it back into flow as relPo.

    Of course, this prostrates itself in front of the proverbial equine of short stature when it comes to keyboard navigation -- but that's why it's generally a piss poor garbage idea to hide sections of content this way in the first place... NOT something I'd advocate doing on a website no matter how 'pretty' or 'neat' the effect is.
     
    deathshadow, Nov 3, 2013 IP