2 “style” inline css img tags?

前端 未结 4 923
一个人的身影
一个人的身影 2021-01-01 02:42

I have the following tag

\"25\"/

        
相关标签:
4条回答
  • 2021-01-01 02:58

    You don't need 2 style attributes - just use one:

    <img src="http://img705.imageshack.us/img705/119/original120x75.png" 
                                         style="height:100px;width:100px;" alt="25"/>
    

    Consider, however, using a CSS class instead:

    CSS:

    .100pxSquare
    {
      width: 100px;
      height: 100px;
    }
    

    HTML:

    <img src="http://img705.imageshack.us/img705/119/original120x75.png" 
                                              class="100pxSquare" alt="25"/>
    
    0 讨论(0)
  • 2021-01-01 03:01

    Do not use more than one style attribute. Just seperate styles in the style attribute with ; It is a block of inline CSS, so think of this as you would do CSS in a separate stylesheet.

    So in this case its: style="height:100px;width:100px;"

    You can use this for any CSS style, so if you wanted to change the colour of the text to white: style="height:100px;width:100px;color:#ffffff" and so on.

    However, it is worth using inline CSS sparingly, as it can make code less manageable in future. Using an external stylesheet may be a better option for this. It depends really on your requirements. Inline CSS does make for quicker coding.

    0 讨论(0)
  • 2021-01-01 03:13

    You should use :

    <img src="http://img705.imageshack.us/img705/119/original120x75.png" style="height:100px;width:100px;" alt="25"/>
    

    That should work!!

    If you want to create class then :

    .size {
    width:100px;
    height:100px;
    }
    

    and then apply it like :

    <img src="http://img705.imageshack.us/img705/119/original120x75.png" class="size" alt="25"/>
    

    by creating a class you can use it at multiple places.

    If you want to use only at one place then use inline CSS. Also Inline CSS overrides other CSS.

    0 讨论(0)
  • 2021-01-01 03:16

    if use Inline CSS you use

    <img src="http://img705.imageshack.us/img705/119/original120x75.png" style="height:100px;width:100px;" alt="705"/>
    

    Otherwise you can use class properties which related with a separate css file (styling your website) as like In CSS File

    .imgSize {height:100px;width:100px;}
    

    In HTML File

    <img src="http://img705.imageshack.us/img705/119/original120x75.png" style="height:100px;width:100px;" alt="705"/>
    
    0 讨论(0)
提交回复
热议问题