Support » Theme: Twenty Fifteen » Remove underline on certain links

  • Resolved ant123

    (@ant123)


    I searched for a solution and tried various things before posting, but to no avail.

    I just want to be able to remove the underline of some links in my Twenty Fifteen pages.

    I tried a good old dirty inline css with text-decoration:none; in the link tag.
    I tried to create a class for links I didn’t want to be underlined.
    I tried to remove the ouline as it seemed to be this when I inspected the links.

    Nothing works.

    Thanks!

    • This topic was modified 1 year, 9 months ago by  ant123.
Viewing 12 replies - 1 through 12 (of 12 total)
  • I tried a good old dirty inline css with text-decoration:none; in the link tag.
    I tried to create a class for links I didn’t want to be underlined.
    I tried to remove the ouline as it seemed to be this when I inspected the links.

    Have you tried border:none it?

    
    <a href="#" style="border:none;" class="">test link</a>
    
    

    Super duper!
    It worked
    Thanks!

    It didn’t work for me. See bottom of [1]. I have Twently Twelve with a child css (pasted below, but I don’t see that it would change link properties). The CSS elements are described at [2].

    The html you you had suggested is changed by WordPress to:
    <a class="" style="border: none;" href="#">test link</a>
    but I guess it’s parsed at the end of line, so sequence isn’t important(?)

    [1] http://www.teigfam.net/oyvind/home/nokkelversene/144-nokkelverset/
    [2] http://www.teigfam.net/oyvind/home/technology/061-wordpress/

    @import url("../twentytwelve/style.css");
    
    /* Thanks to paulwpxp 2013 07 26 */
    /* ----- blockquote reduce space ----- */
    .entry-content blockquote,
    .comment-content blockquote {
        padding-top: 0;
        padding-bottom: 0;
    }
    /* ----- h2 color  ----- */
    .entry-content h2 {
        color: #ff0000;
    }
    
    /* Thanks to Chris Rockwell 2013 08 14 at css-d@lists.css-discuss.org */
    /* Make Reference ordered list as [x] */
    ol.ol_href {
        list-style-type: none;
        counter-reset: section;
        padding-left: 0;
    }
    ol.ol_href li {
      display: table-row
    }
    ol.ol_href li:before {
        counter-increment: section;
        content: "[" counter(section) "] ";
        padding-right: 1em;
        display: table-cell;
    }
    
    /* Thanks to WPyogi 2013 11 18 */
    p.p_vline_left_gray {
       border-left: 1px solid #C0C0C0;
       margin-left: 10px;
       padding-left: 10px;
    }
    p.p_vline_left_red {
       border-left: 1px solid #ff0000;
       margin-left: 10px;
       padding-left: 10px;
    }
    p.p_noline_left {
       border-left: 0px;
       margin-left: 10px;
       padding-left: 10px;
    }
    
    /* Teig 2014 02 03 */
    code.code_x_courier {
        line-height:100%;
        font-weight:bold;
        font-family:"Courier";
    }
    code.code_x {
        line-height:100%;
        font-weight:bold;
    }
    
    /* Thanks to Andrew av http://wordpress.org/support/topic/png-and-gif-images-have-thin-border-around-them */
    /* Removes borders around (all?) pictures */
    .entry-content img,
    .comment-content img,
    .widget img,
    img.header-image,
    .author-avatar img,
    img.wp-post-image {
       box-shadow: none;
    }
    • This reply was modified 1 year, 9 months ago by  aclassifier.

    The sequence doesn’t matter.

    For the theme you are using, use text-decoration: none; instead.

    FYI please post question in theme’s own support forum, this one is for Twenty Fifteen theme.

    Thanks! I didn’t imagine that there would be different solutions for the two themes. Not very portable, is it? Could I have made the difference in the child css, like define a class_link_no_underline defined there instead of just a local empty class?

    Could I have made the difference in the child css, like define a class_link_no_underline defined there instead of just a local empty class?

    Yes you are right, but also noted that in WP we make use of “post class” when we want some element styled differently across the site conditionally.

    For example, to make all links become pink only if it’s in post tagged with “pink.”

    .tag-pink a { color: pink; }

    See more details here
    https://codex.wordpress.org/Function_Reference/post_class

    Interesting!

    If I add this in my style.css:

    a.a_link_no_underline {
        text-decoration: none;
        /* border: none; */
    }

    and use it like this:

    <a class="a_link_no_underline" href="http://www.teigfam.net/oyvind/home/nokkelversene/">Test</a>

    then the underline is still present. What do I do wrong?

    I see nothing wrong there, probably caching issue?

    It was (blush)! Thanks!

    By the way, is there a way in CSS to make it general with macros, or could this be wrapped in PHP or JavaScript? I have written it up in C_CSS here, as if that were a language, with some assumed semantics of text-decoration and border. Also, is there some define here for the theme chosen? But then, the style.css wouldn’t like anything else than CSS, would it? Also, why in the world would the use of CSS differ for different themes? Will my other CSS examples also differ? Wouldn’t one use the freshest html always?

    #if TWENTY_TWELVE 
        a.a_link_no_underline { text-decoration: none;}
    #elif defined TWENTY_FIFTEEN 
        a.a_link_no_underline { border: none;}
    #else
        a.a_link_no_underline { border: none;}
    #endif
    • This reply was modified 1 year, 9 months ago by  aclassifier.

    Themes must use different CSS because they want different designs. We can have a website without CSS at all, and it’s still workable because all web browsers have default CSS just good enough for normal usage, but people build website differently so it requires different CSS code.

    In your example, the purpose is to write additional CSS to override theme’s own style conditionally based on theme name. Problem is we don’t and will never have WordPress-theme-name conditional tag in CSS. Even if there is, to have 1 set or 1 file of additional CSS to override all theme is impossible, because it’s the target element that matter.

    Anyway, we can still target a specific element and apply set of properties to override all other possible properties (for this element only). So in this case, your example code can be like this

    
    a.a_link_no_underline { 
    	border: none;
    	text-decoration: none;
    }
    

    this code works for ANY theme that defines underline style with either border or text-decoration.

    Problem is we don’t and will never have WordPress-theme-name conditional tag in CSS

    As having coded embedded applications for some 35 years I could not agreed more! With Pascal, Modula 2, occam etc. the languages didn’t have that kind of possibility. Then we started with C and it’s easy to fall. But newer languages like go also are nice, no preprocessor etc.

    So, sound design WordPress! That’s why I said, in the survey, as the main reason I am using it: “WordPress works”.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Remove underline on certain links’ is closed to new replies.