Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I put a <style>...</style> tag within the body of a HTML file to send in email?

Tags:

html

css

email

Since a lot of email clients ignore the HEAD tag, can I embed an inline stylesheet in the body?

like image 850
Manu Avatar asked Oct 22 '08 13:10

Manu


People also ask

Can I use style tag inside body?

You can place HTML style tags in <head> or <body> elements. We'd recommend choosing the first option, as that allows you to keep the content and styling information separate. Note: you can also use <link> elements to apply styles kept in external stylesheets.

Where do you place the tag style </ style in an HTML file?

Adding Styles to HTML Elements Inline styles — Using the style attribute in the HTML start tag. Embedded style — Using the <style> element in the head section of the document.

Does style go inside HTML?

The <style> tag is used to define style information (CSS) for a document. Inside the <style> element you specify how HTML elements should render in a browser.


2 Answers

The short answer is no. Gmail strips the tag and it's content.

Hotmail, Yahoo! Mail and Windows Live Mail does not strip style-tags in the body-element.

But take a look at "The Ultimate Guide to CSS" for HTML email over at Campaign Monitor.

like image 77
cllpse Avatar answered Sep 23 '22 20:09

cllpse


Creating an HTML email that works in every email client is hard. I spent several months refining a good looking template.

http://commadot.com/the-holy-mail/ - original blog with my findings.

http://commadot.com/email-best-practices/ - latest greatest.

Specific answer to your question: Gmail will be ok with style="" but not with a <style> block.

like image 35
Glen Lipka Avatar answered Sep 23 '22 20:09

Glen Lipka