Skip to main content
Level 9
December 14, 2015
Question

Defining height and width on images

  • December 14, 2015
  • 2 replies
  • 5330 views

I might be crazy....but I thought I read something a while ago which said that when coding for email, it was best to avoid hard-coding values for images (through width="" and height="" attributes). I thought this might have been for mobile or Outlook, but I'm not sure.

What's best practice here? I know I should be creating images at the actual size I want them displayed on desktop - so how will setting a hard-coded width and height affect my mobile rendering? Are there any benefits and drawbacks?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Frank_Breen2
Level 8
December 15, 2015

When doing responsive email templates it's best not to define the width and height, then in your @media query you have to set the image css to: width: 100% !important; height: auto;

If you're not going responsive emails, then defining the width and height should not effect the template on different clients.  

Dan_Stevens_
Level 10
December 15, 2015

You'll need to manually remove the H and W attributes/values from the HTML (you can't just delete the values from the image properties box) since Marketo inserts these automatically each time you place a new image within an email.

Frank_Breen2
Level 8
December 15, 2015

Totally correct Dan, sorry I'm so use to just doing the it in the raw HTML; also I tokenise my images so we only have to include the name rather than using the image insert in the WYSIWYG editor (which is a great work around too).

Level 9
December 15, 2015

Ahhh very interesting. Thanks everyone. Frank, I'm also using the raw HTML which I then paste into Marketo's email editor. So I assume my width="" tag would be fine then, and wouldn't insert values automatically?

We are also using responsive templates with media queries, and use exactly the CSS code you have above, so that's heartening to find it's ok!

Sounds like I am on the right track by not defining it, and then using the media query to make it 100% width and auto height.

Thanks all!

Frank_Breen2
Level 8
December 16, 2015

Correct, Marketo only automatically inserts the width and height when you use the Insert/Edit Image in the Rich Text Editor.