hide img tag if src is empty but without javascript/jQuery or css3

You can use [attr=val] selector

 img[src=“”]{display: none;}

The above selector will simply match, if the src attribute has no value.

Alternatively, if you want to reserve the space taken by img tag, you might like to use 
visibility: hidden; instead of display: none; 
as display: none; will simply mess your layout 
where visibility: hidden; will reserve the space, it will just hide the img.

Enjoy Demo:


Hope this help !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s