9 Replies - 1820 Views - Last Post: 18 December 2013 - 01:38 PM

#1 RobbyBobby75   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-December 13

Newbie Question About CSS/HTML Links

Posted 17 December 2013 - 11:03 AM

I'm currently a mod over on Reddit in r/DrWhoLegacy. I recently added a link in the subreddit that links back to the main page. This link opens in a new tab and I was wondering if there was a way to force it to open in the same tab in CSS. Reddit doesn't allow mods access to the HTML code for the Subreddits we mod for.

My current code:
.side .md [href="http://www.reddit.com/r/DrWhoLegacyCSS"] {
    position: absolute;
    top: 176px;
    left: 24px;
    font-size: 12px;
    background: #fff;
    color: #333;
    border-left: 6px solid #4D6277;
    padding: 0 12px;
}


I've looked at Reddit's r/CSSHelp and Googled the problem and found no solutions. Any help offered is much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Newbie Question About CSS/HTML Links

#2 BenignDesign   User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 8191
  • View blog
  • Posts: 12,541
  • Joined: 28-September 07

Re: Newbie Question About CSS/HTML Links

Posted 17 December 2013 - 11:10 AM

CSS cannot be used to designate where a link opens. That is the job of the HTML target attribute.
Was This Post Helpful? 4
  • +
  • -

#3 RobbyBobby75   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-December 13

Re: Newbie Question About CSS/HTML Links

Posted 17 December 2013 - 11:23 AM

Thanks for the answer. Cheers.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4288
  • View blog
  • Posts: 13,594
  • Joined: 08-June 10

Re: Newbie Question About CSS/HTML Links

Posted 17 December 2013 - 11:42 PM

browsers usually open destinations with a given protocol (like http://) in a new whindow while opening relative paths in the same.
Was This Post Helpful? 0
  • +
  • -

#5 BenignDesign   User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 8191
  • View blog
  • Posts: 12,541
  • Joined: 28-September 07

Re: Newbie Question About CSS/HTML Links

Posted 18 December 2013 - 01:34 AM

Really? I have never noticed that before! I'm trying to think back through all my old projects, but the 3am fog is preventing my brain from functioning.
Was This Post Helpful? 0
  • +
  • -

#6 nfc212   User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 17
  • Joined: 08-December 13

Re: Newbie Question About CSS/HTML Links

Posted 18 December 2013 - 06:42 AM

For anyone bemused by the first line in the CSS snippet above, what you are seeing is a CSS selector.

It is essentially saying apply the following style properties to any link where the target is explicitly http://www.reddit.com/r/DrWhoLegacyCSS which is within an element with class="md" within a parent element which has class="side".

Very powerful things CSS selectors and very much overlooked.

As regards opening links in new windows the only way I know is to use target="_blank". However this will only validate in pages using a transitional DTD and will cause a strict DTD to fail validation. I notice most WP generated sites now employ same window links. I can never understand the logic of liberally sprinkling your pages with trap doors which allow your hard won visitors to noddy off elsewhere at the click of a button.
Was This Post Helpful? 0
  • +
  • -

#7 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Newbie Question About CSS/HTML Links

Posted 18 December 2013 - 07:42 AM

View PostBenignDesign, on 18 December 2013 - 08:34 AM, said:

Really? I have never noticed that before!

Yea, I was thinking that same thing. I've done entire projects using nothing but URLs with the protocol included, and I don't recall any problems with things opening in new windows/tabs without a target. - A quick test on the current versions of the major browsers seems to support that.
Was This Post Helpful? 1
  • +
  • -

#8 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Newbie Question About CSS/HTML Links

Posted 18 December 2013 - 07:49 AM

View Postnfc212, on 18 December 2013 - 01:42 PM, said:

I can never understand the logic of liberally sprinkling your pages with trap doors which allow your hard won visitors to noddy off elsewhere at the click of a button.

It's a matter of not taking the user's control from them. Whether or not they want a link to be opened in a new window/tab should be their call, not yours. An annoyed user isn't likely to stick around. If you've got decent content, they'll be back.
Was This Post Helpful? 1
  • +
  • -

#9 BenignDesign   User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 8191
  • View blog
  • Posts: 12,541
  • Joined: 28-September 07

Re: Newbie Question About CSS/HTML Links

Posted 18 December 2013 - 07:54 AM

We have one department on campus here that insists every link on their portion of the site MUST open in a new tab/window... be it an internal link or an external link. When I'm making site updates or modifications on their section of the site, by the time I'm finished testing, checking, and verifying data, I'll have three browsers frozen from the overload of running 42 tabs a piece because every link in every test popped open a new one... and I end up having to hard reboot my system to regain control of it. Makes me want to throw my workstation, the server, and the entire staff of the department in question off the roof of the building. :taz:
Was This Post Helpful? 0
  • +
  • -

#10 nfc212   User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 17
  • Joined: 08-December 13

Re: Newbie Question About CSS/HTML Links

Posted 18 December 2013 - 01:38 PM

View PostAtli, on 18 December 2013 - 07:49 AM, said:

View Postnfc212, on 18 December 2013 - 01:42 PM, said:

I can never understand the logic of liberally sprinkling your pages with trap doors which allow your hard won visitors to noddy off elsewhere at the click of a button.

It's a matter of not taking the user's control from them. Whether or not they want a link to be opened in a new window/tab should be their call, not yours. An annoyed user isn't likely to stick around. If you've got decent content, they'll be back.


Hmm, fair point.

I must admit my own action now when clicking a link on a page I haven't finished with is to right click>Open Link In New Tab. Personally I find being carted off elsewhere annoying.

Well I suppose you can't please everybody. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1