Doctype problem displaying SVG with Safari

前端 未结 2 888
南旧
南旧 2020-12-12 04:35

I have several SVG images I\'d like to layout on a page. Firefox and Chrome have given me no issues whatsoever, but Safari only seem to display the SVG image if and only if

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 04:55

    The reason .xhtml works in Safari and .html doesn't is that Safari needs to treat the document as XML to allow embedded SVG. The latest versions of Firefox and Chrome use a HTML5 parser which allows SVG to be embedded in plain HTML documents, so they should work with both.

    To have it render properly in Safari you need to set the content type to application/xhtml+xml. Use this in your PHP file before you output any content:

    
    

提交回复
热议问题