John Sudds - MSFT

I received the following question as MSDN feedback on the VML documentation.

why is the following html not displaying as I want The start point of the line and the rect should be on one point.

Code Snippet

<html xmlns:v="urn:schemas-microsoft-com:vml">



v\:* { BEHAVIOR: url(#default#VML) }




<v:rect style="POSITION:absolute; LEFT:300px; TOP:300px; WIDTH:100px; HEIGHT:100px"/>

<v:line from="300,300" to="400,400"/>



Re: Internet Explorer Web Development What is wrong with this VML?

John Sudds - MSFT

Your question is a valid one, and maybe you¡¯ve already figured it out by now.

In your example, the RECT element is absolutely positioned, but the line is not. The line is painted starting at point (300,300) away from the bounding box of the containing div, in this case the BODY tag. The line is offset due to the default margins of the body, which the following CSS rule would remove:

body { margin:0 }

However, since you are painting a line to coincide with an absolutely positioned RECT, the LINE should also be absolutely positioned.

<v:rect style="POSITION:absolute; LEFT:300px; TOP:300px; WIDTH:100px; HEIGHT:100px" />

<v:line style="POSITION:absolute; LEFT:300px; TOP:300px;" from="0,0" to="100,100" />

For more complex drawings, it is easier to set all VML elements to position:absolute and place the elements inside a DIV that is located at the correct location on the page.

Code Snippet

<html xmlns:v="urn:schemas-microsoft-com:vml">

<style type="text/css">

v\:* {





<div style="position:absolute; left:300px; top:300px;">

<v:rect style="width:100;height:100" />

<v:line from="0,0" to="100,100" />


Hope that helps.