Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

style vs. tag

Enthusiast ,
Dec 19, 2016 Dec 19, 2016

Why is it that on an img tag the float property only works if applied to the inline style tag of img... why does it not apply when added to the CSS rule in the external stylesheet?

Thank you.

294
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 19, 2016 Dec 19, 2016

r_tist wrote:

Why is it that on an img tag the float property only works if applied to the inline style tag of img... why does it not apply when added to the CSS rule in the external stylesheet?

Thank you.

Sometimes you might need to dig a bit deeper like:

<div class="container"><img src="my_image.jpg" class="img_float_left"></div>

Rather than:

.img_float_left {

float: left;

}

You may have to use

.container .img_float_left {

float: left;

}

or if youre completely stuck but I don't advice it give the img tag a

...
Translate
LEGEND ,
Dec 19, 2016 Dec 19, 2016
LATEST

r_tist wrote:

Why is it that on an img tag the float property only works if applied to the inline style tag of img... why does it not apply when added to the CSS rule in the external stylesheet?

Thank you.

Sometimes you might need to dig a bit deeper like:

<div class="container"><img src="my_image.jpg" class="img_float_left"></div>

Rather than:

.img_float_left {

float: left;

}

You may have to use

.container .img_float_left {

float: left;

}

or if youre completely stuck but I don't advice it give the img tag a unique id (if that doesnt kill it then you have something else going on in your code)

<img src="my_image.jpg" id="img_float_left">

#img_float_left {

float: left;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines