locked
Style tag on RRS feed

  • Question

  • My problem is that the attributes WIDTH/HEIGHT  are located in 'style' tag in my source code. These attributes should be in the img tag.

     

    Why is EW generating it this way? How do i change the settings for this problem?

     

    Thanks Pete

    Saturday, October 9, 2010 1:17 AM

All replies

  • It's not a problem. It is one of two standard ways of specifying img width and height (and only img width and height; HTML presentational attributes are deprecated for everything but images). You can use either this

    <img src="myImage.jpg" height="300" width="200" />

    or this

    <img src="myImage.jpg" class="sidebarHeader" />

    with CSS of

    .sidebarHeader {
       height:300px;
       width:200px;
    }

    Both are equally valid, and both are standards-compliant.

    EW, by default, strives to produce standards-compliant markup and CSS. There is a setting on the CSS tab in Tools|Page Editor Options that will let you check the option to use height and width attributes for images instead of CSS. Check that box.

    [EDIT: Forgot to mention, you can also use inline CSS, similar to the HTML properties, so <img src="myImage.jpg" style="height:300px; width:200px;" />. When used in this fashion, the attributes must follow CSS convention, with colon versus equal sign, specified units, and semicolon terminators for all but the last attribute listed, for which it is optional.]

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.
    Saturday, October 9, 2010 2:17 AM
  • [EDIT: Forgot to mention, you can also use inline CSS, similar to the HTML properties, so <img src="myImage.jpg" style="height:300px; width:200px;" />. When used in this fashion, the attributes must follow CSS convention, with colon versus equal sign, specified units, and semicolon terminators for all but the last attribute listed, for which it is optional.]

    A  clarification of de minimums significance;

    Attributes have an equal sign after them like for example in the above "style=" style is an attribute.

    Properties have a colon after them like height: or width:

    On the right side of the : are values.

    style="property :value"


    What is inconsistent/confusing is that in the newer inline style syntax the height: is a property but in the older syntax of height="300" then height is an attribute.

     

     

     

    Saturday, October 9, 2010 6:05 AM
  • Why is EW generating it this way? How do i change the settings for this problem?

     

    Thanks Pete


    With EW open, click Tools > Page Editor Options > CSS tab
    At the bottom check the box: Use width and height attributes for images instead of CSS.

     


    Expression Web MVP
    • Proposed as answer by Steve Easton Saturday, October 9, 2010 1:35 PM
    Saturday, October 9, 2010 1:35 PM
  • I too prefer to have image height and width in the image element not in either an external or inline style. Go to Tools > Page Editor Options > CSS Tab and place a check in the "Use width and height attributes for images instead of CSS".

    If you are like me there are two other things you will change while you are there. First, change Page properties on the <body> tag to (rules) instead of (inline styles), and Sizing, positioning,, and floating to (classes) from the default (inline styles).


    MS MVP Expression Tutorials & Help http://by-expression.com & Expression Web forums
    Saturday, October 9, 2010 4:50 PM
  • I have this checked already, it is strang because it doesnt happen on all of my websites.
    Pete P
    Sunday, October 10, 2010 4:24 AM
  • I use webceo to test my website for errors and it shows an error when its in a style. I have "Use width and height attributes for images instead of CSS" Checked but it still puts it in a style.

     


    Pete P
    Sunday, October 10, 2010 5:34 AM
  • I've never had EW create styles for height/widtyh once I've put hte checkmark in.

    As for "webceo" whatever that it, if it shows an error when you have height/width in a style then the application is wrong and I wouldn't rely on it. Use the W3C validator instead.


    MS MVP Expression Tutorials & Help http://by-expression.com & Expression Web forums
    Sunday, October 10, 2010 7:38 PM
  • "I use webceo to test my website for errors and it shows an error when its in a style. "

    It's not an error.  Well, it is - but it's a webceo error, not your page error, if it's telling you that.  ;)

    "Checked but it still puts it in a style."

    It won't undo previously created styles - is that what you mean?  That would be normal.  It affects *new* images put on your pages. 

    Monday, October 11, 2010 12:16 AM