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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...