• How To?
  • Tips ‘n Tricks
  • WordPress
  • Snippets
  • Software
    • Browsers
    • Downloads
  • Web
  • Tools
    • Character Counter
    • chmod Calculator
    • Entities Encoder
    • Live HTML Editor
    • My IP
  • Contact
Twitter Facebook Google+ RSS
You are here: SumTips » Snippets » CSS Snippets » Show Link URL from HREF Attribute Using CSS

Show Link URL from HREF Attribute Using CSS

Posted on May 17, 2012 by Renji | Short URL: http://sumtips.com/?p=6562

We can use CSS to display the URL of a link after the link. For this we don’t need to modify HTML as all work is done by CSS.

This is the complete CSS to do this:

a:after{
    content: ' ' attr(href);
    // Style URL
    font-style:italic;
    color:blue;
}

The CSS feature :after allows us to add any content after an element, so to show URLs after links we are using:

a:after{

}

As for the URL itself, we will get it from the link’s href attribute. This is done using a method called attr():

 attr(href)

You can access other attributes (ex. title) this way.

Finally, you can also style the displayed content using CSS just like any other element:

a:after{

    font-style:italic;
    color:blue;
}

Tweet

Related posts:

  • CSS Attribute Selectors
  • Password Protect Firefox Bookmarks with Link Password
  • Hotkey To Change Explorer View, Show/Hide Navigation Bar, Detail Bar
Categories: CSS Snippets
Scaleable Full Screen Background Image with CSS3
Create a ‘|’ bar Separated Horizontal Menu with CSS3

  • Get Updates via Email

  • Recent Posts

    • CMS2CMS: Migrate Site from Drupal or Joomla to WordPress
    • WordPress: Add Preview Button in Distraction Free Writing
    • How to Activate or Deactivate Individual Jetpack Modules
    • Windows 8: Auto Update Defender with Windows Update Disabled
    • Automatically Start and Close Programs at Specific Time
    • How to Copy Code from Notepad++ with Syntax Highlighting
  • Random Posts

    • Opera 11 Will Support Extensions
    • How To Make A File Read-Only In Windows
    • Have a Social YouTube Video Watching Experience
    • CBX Shell: View RAR and ZIP Archives Thumbnail
    • Directly Upload Videos from Google Drive to YouTube
    • Be The Mayor, Helps You Win Foursquare Mayorship Battles
  • Categories

    • Blogging
    • Games
    • Google
    • How To?
    • Linux
    • Microsoft
      • Windows
    • Miscellaneous
    • Phone
    • Snippets
      • AutoHotkey Snippets
      • CSS Snippets
      • htaccess Snippets
      • JavaScript Snippets
      • PowerShell Snippets
      • WordPress Snippets
    • Social
    • Software
      • Browsers
    • Tips 'n Tricks
    • Wallpapers
    • Web
© SumTips. Contact | Sitemap | Privacy Policy