Targeting CSS Based on Attribute Values
ExamplesInput Name
<input class="form-control" name="inputOne"/> <style> input[name="inputOne"]{ border-color:red; } </style>
Input Name Starts With
<input class="form-control" name="randomInputOne"/> <input class="form-control mt-3" name="randomInputTwo"/> <style> input[name^="random"]{ border-color:blue; } </style>
Input Name Ends With
<input class="form-control" name="threeRandomInput"/> <input class="form-control mt-3" name="fourRandomInput"/> <style> input[name$="Input"]{ border-color:green; } </style>
Input Name Includes
<input class="form-control" name="nameIncludesThis"/> <input class="form-control mt-3" name="otherIncludesThat"/> <style> input[name*="Includes"]{ border-color:orange; } </style>
Target a href element
<a href="https://www.prodjex.com">This is a link.</a> <style> a[href="https://www.prodjex.com"]{ color:brown; } </style>
Target data-value element
<a href="https://www.prodjex.com/web-development-blog/" data-value="webLink">This is another link.</a> <style> [data-value="webLink"]{ color:purple; } </style>