Q:

D3.js - Creating a rectangle?

I'm just starting to learn d3.js, and I have a very simple program that just creates a rectangle: 
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title> D3 Slider </slider>
     <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<div>
    <script>
        //make the svg container 
        var svgContainer = d3.select("body").append("svg")
                                       .attr("width",200)
                                       .attr("height",200); 
        //make the rectangle 
        var rectangle = svgContainer.append("rect")
                                     .attr("x",150)
                                     .attr("y",50)
                                  .attr("width",50)
                               .attr("height",140);
    </script>
</div>

</body>
</html>

But when I run it, the rectangle does not create and I get a blank screen? Do I have to add the SVG element to the div? Sorry if this is a simple question, but I just could not figure it out!

A:

<title> D3 Slider </slider> was being closed with </slider> changed back to </title> makes the code work perfectly 
it is also recommended to move script to before closing </body> or in <head> tag underneath d3.js script

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>D3 Slider</title>
  <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>

<body>
  <div>

  </div>
  <script>
    //make the svg container 
    var svgContainer = d3.select("body").append("svg")
      .attr("width", 200)
      .attr("height", 200);
     //make the rectangle 
    var rectangle = svgContainer.append("rect")
      .attr("x", 150)
      .attr("y", 50)
      .attr("width", 50)
      .attr("height", 140);
  </script>
</body>

</html>

