-1

As i am new learner, i'm trying this css styles by watching YT videos

If you see the code below, i am having "../images/..." as my 'src' attribute value in my html

so in css, i have written img[src="../images/"] {...}, which is same as in html but the styles didn't work here

But when i gave a caret like this img[src^="../images/"] as said in video then the written style has worked

why is it? Please explain

img[src="../images/"] {
  border: 10px solid green;
}
<img src="../images/lesson img-2.jpg">

    <h2 class="subtitle" id="subtitle-id" style="color: green;">Contact Us</h2>
    
    <form>
      <input type="text" placeholder="Full Name">
      <input type="email" placeholder="Email">
      <textarea></textarea>
      <button>Submit</button>   
    </form>

img[src^="../images/"] {
  border: 10px solid green;
<img src="../images/lesson img-2.jpg">

    <h2 class="subtitle" id="subtitle-id" style="color: green;">Contact Us</h2>
    
    <form>
      <input type="text" placeholder="Full Name">
      <input type="email" placeholder="Email">
      <textarea></textarea>
      <button>Submit</button>   
    </form>
ESF
  • 17
  • 5
  • take the time to read the full duplicate and all the relevant links in it. There is no need to repeat the same question (https://stackoverflow.com/questions/72315700/why-imgsrc-images-doesnt-work-and-why-imgsrc-iamges), it will get closed the same way – Temani Afif May 20 '22 at 10:12
  • 2
    the ^="../images/" means the css selector will search for an img tag with a src attribute which starts with "../images/" and ends by whatever, where strict ="../images/" means the src must be "../images/" – Adnane Ar May 20 '22 at 10:12
  • @TemaniAfif, i don't know stack overflow much, all i thought is, we have to post our questions & get the answers from experts. But a lot is happening here, why i repeated my last question is bcuz i deleted it after i said the question is already asked in community, when i checked it wasn't what i want but that question got down votes instead of someone answering. So, i got frightened if down votes continue may be i get banned from stock overflow and deleted it. As i didn't get the answer for my question, i posted it again with modified title. If u have any suggestions please help me out here – ESF May 20 '22 at 11:36

0 Answers0