Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to draw a rectangle in HTML or CSS?

I am trying to draw a rectangle and I found the website for css code(http://css-tricks.com/examples/ShapesOfCSS/). How do I put together in HTML? In other words, how do I define #rectangle in HTML.

Facebook always has blue rectangle at the top of each page. What is the best way to achieve like them?

I appreciate if someone could help me.

like image 484
user3014926 Avatar asked Dec 19 '13 19:12

user3014926


People also ask

How do you position a rectangle in HTML?

. rectangle{ width:200px; height:300px; background-color:#000000; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); } This css code will definitely work for putting rectangle in the center.


4 Answers

Fiddle

HTML

<div id="rectangle"></div>

CSS

#rectangle{
    width:200px;
    height:100px;
    background:blue;
}

I strongly suggest you read about CSS selectors and the basics of HTML.

like image 128
tjboswell Avatar answered Oct 07 '22 06:10

tjboswell


Use <div id="rectangle" style="width:number px; height:number px; background-color:blue"></div>

This will create a blue rectangle.

like image 40
JetMashKangaroo Avatar answered Oct 07 '22 05:10

JetMashKangaroo


SVG

Would recommend using svg for graphical elements. While using css to style your elements.

#box {
  fill: orange;
  stroke: black;
}
<svg>
  <rect id="box" x="0" y="0" width="50" height="50"/>
</svg>
like image 14
Persijn Avatar answered Oct 07 '22 06:10

Persijn


I do the following in my eBay listings:

<p style="border:solid thick darkblue; border-radius: 1em; 
          border-width:3px; padding-left:9px; padding-top:6px; 
          padding-bottom:6px; margin:2px; width:980px;">

This produces a box border with rounded corners.You can play with the variables.

like image 6
BeenThere Avatar answered Oct 07 '22 06:10

BeenThere