The src*="http://"
selector is incorrect for this, since *=
indicates that it will fetch any attribute location , the correct selector to use would be ^=
, CSS2 selectors .1 / 2.2 for attributes are as follows:
-
[data-foo^="bar"]
starts with the set value
-
[data-foo$="bar"]
ends with set value
-
[data-foo*="bar"]
contains the value (regardless of whether it is start, middle, or end)
-
[data-foo~="bar"]
causes the behavior to be similar to that of the class selector, ie "bar"
is the value that will be evaluated between spaces, eg
<div data-foo="foo bar baz"></div> <!-- será pego pelo seletor -->
<div data-foo="foo bar bar"></div> <!-- será pego pelo seletor -->
<div data-foo="bar foo baz"></div> <!-- será pego pelo seletor -->
<div data-foo="a b c"></div> <!-- NÃO será pego pelo seletor -->
<div data-foo="a bar c"></div> <!-- será pego pelo seletor -->
-
[data-foo|="bar"]
This selector is used usually to pick up representing languages, as it will look for elements like:
<div data-foo="bar"></div>
<div data-foo="bar-baz"></div>
That is, it should be exactly "bar"
or it should start with bar-
, a use with elements indicated in Portuguese (and variants):
Then as I said at the beginning, to get attributes that start with http://
the correct would be to use ^=
like this:
a[href^="http://"] {
color: red;
}
img[src^="http://"] {
border: 1px solid red;
}
<a href="http://google.com">link http</a> <br>
<a href="https://google.com">link https</a> <hr>
<img src="http://i.stack.imgur.com/6UVKr.jpg"alt="imagem com http"> <br>
<img src="https://i.stack.imgur.com/6UVKr.jpg"alt="imagem com https">
Now imagine that your image has a dynamic URL like this:
<img src="http://site.com/ptoxy.php?url=https://foobarbaz.com/imagem.jpg">
IfyouuseCSSlikethis:
img[src*="https://"] {
border: 1px solid red;
}
It will be applied to this image, when it should not
Source: link