Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add properties to <a> in CSS

For every individual <a> tag I have on my website I have to add the properties "target="_blank" rel="noopener noreferrer". It doesn’t work when I put this in my CSS stylesheet however:

a {
target: "_blank";
rel: "noopener noreferrer";
}

It says the properties are unknown, which can’t make sense because they are recognized and work when I put them within the actual tag.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Only styling can be added with css not html attributes. Eg
 You can replace below inline css style with external css
     <a href="#" style="color:blue">

    to
    <a href="#">
     a{
        color: blue;
        }

  Whatever is there in style attribute inline can be replaced with css. 
         <a href="#" target="_blank"> 
  This is target attribute and it cannot be replaced using css. Only 
   inline css using style can be replaced with external css.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading