Jump to content

How to apply css to all anchor texts /links


Recommended Posts


I like to apply css to all anchor texts regardless how the a links are coded. I put that code and I notice that css does not apply to all anchors. 

/* unvisited link */
a:link {
  color: red;

/* visited link */
a:visited {
  color: green;

/* mouse over link */
a:hover {
  color: hotpink;

/* selected link */
a:active {
  color: blue;


Below shows two examples how anchors look like on the page:

<nav class="toolbar-lining clearfix" role="navigation" aria-label="Administration menu">
<h3 class="toolbar-tray-name visually-hidden">Administration menu</h3>
<div class="toolbar-menu-administration"><ul class="toolbar-menu">
<li class="menu-item menu-item--collapsed"><a href="/admin/content" title="Find and manage content." id="toolbar-link-system-admin_content" class="toolbar-icon toolbar-icon-system-admin-content" data-drupal-link-system-path="admin/content">Content</a></li>
<li class="menu-item menu-item--collapsed"><a href="/admin/structure" title="Administer blocks, content types, menus, etc." id="toolbar-link-system-admin_structure" class="toolbar-icon toolbar-icon-system-admin-structure" data-drupal-link-system-path="admin/structure">Structure</a></li>
<ul class="menu menu--main nav navbar-nav responsive-menus-simple" id="rm-no-id">
                      <li class="first">
                                        <a href="/" data-drupal-link-system-path="<front>" class="is-active">Home</a>
                                        <a href="/node/4" data-drupal-link-system-path="node/4">How it works</a>
                                        <a href="/node/6" data-drupal-link-system-path="node/6">About Us</a>
                      <li class="last">
                                        <a href="/node/5" data-drupal-link-system-path="node/5">Contact Us</a>

These anchors show different ways in different places like blocks, sections, views, menu, etc. Regardless, how these are coded, how to apply the above styling? Currently, it works for some and does not work for others. Thank you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...