Html Draw Box Around Div

How to Create a Rectangular Box to Comprise Your Text/Pictures with CSS

Draw a box around your content


How to Create a Rectangular Box to Comprise Your Text/Pictures with CSS

past Christopher Heng, thesitewizard.com

Being able to draw a line around a block of text and/or pictures is handy if y'all desire to grouping a section of related items together. This has the visual upshot of placing your text and pictures in a rectangular box. The box serves to separate the content from the rest of the page, and may be used either to emphasize its content, or to make it like an inset in your folio. This tutorial shows you how you can reach this using CSS.

Prerequisites

This article is targeted at those who paw code straight in HTML and CSS. As such, some basic CSS/HTML knowledge is assumed. You lot do non take to be an expert, but you lot will need some working knowledge of what CSS is as well as how you tin can insert CSS into your page.

If you take arrived at this page with the intention of learning more about how to create your own website, you should read my article on How to Commencement Your Own Website instead. It volition take y'all through all the necessary steps of making your ain site. Creating a website is more merely designing the visual appearance.

Using CSS to Draw a Edge Around Your Block of Text and Pictures

Let's say that you have some text or pictures that yous want to enclose in a box.

  1. Create the HTML for the cake. For this tutorial, I shall use a DIV block to enclose the text/pictures.

    <div class="boxed">
    This text is enclosed in a box.
    </div>

    I gave the DIV block a class of "boxed" but you can of course employ some other valid CSS course name. Supervene upon my dummy content with your actual text and/or images.

  2. Next, y'all will need to style the DIV box by calculation a border. In your CSS section, or external CSS file, add the following lawmaking:

    .boxed {
    border: 1px solid green ;
    }

    The CSS code above specifies a 1 pixel edge for the class "boxed". The box volition have a solid green border. An example of a box using this code can exist seen above. I utilize the exact same code, "edge: 1px solid dark-green", to enclose most of the code examples on thesitewizard.com (at the fourth dimension I write this).

    The thickness of the border can be changed if yous find a 1 pixel border too thin for your liking. Similarly, other border styles besides "solid" are also possible. For instance, "dotted" gives yous a dotted border, "dashed" a border consisting of dashes, and "double" a double-lined border. Other values, which may or may not be implemented in your browser (depending on which browser you're using), include "inset", "outset", "ridge" and "groove". These give a 3D effect to your box.

    The colour ("color" in U.s.a. English) of the edge is specified with an RGB value (similar #000 or #000000 for black), or, if information technology is 1 of the sixteen basic colours defined in the CSS specifications, by its color name. If in doubt, use the colour code. Nearly HTML editors and programmer's editors have color pickers which you can employ to select a color by simply clicking on it. The editor so automatically generates the appropriate RGB color value for you, so using a numeric colour value should not be exceptionally hard.

    If you desire to give your box rounded corners, please see the article How to Create Rounded Corners for Your Box Borders in CSS. Y'all can also create coloured boxes in CSS, where the groundwork of the box has a unlike colour from the rest of the page. Another visual effect that tin can be used is to make the box cast a shadow.

That'south it. The process for creating a rectangular box effectually your text/images with CSS is, equally you can see, very simple.

Copyright © 2008-2020 by Christopher Heng. All rights reserved.
Become more free tips and articles similar this, on spider web design, promotion, revenue and scripting, from https://www.thesitewizard.com/.

thesitewizard™ News Feed (RSS Site Feed) Subscribe to thesitewizard.com newsfeed

Exercise yous find this commodity useful? You can learn of new manufactures and scripts that are published on thesitewizard.com by subscribing to the RSS feed. But point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml. You lot can read more nearly how to subscribe to RSS site feeds from my RSS FAQ.

Delight Do Not Reprint This Article

This article is copyrighted. Delight exercise not reproduce or distribute this article in whole or office, in whatever form.

Related Pages

  • How to Design a Two Column Layout for Your Website Using CSS
  • How to Make Your Links Change Colour When the Mouse Hovers Over Information technology (Using CSS)
  • How to Create 3D Buttons Using CSS
  • How to Make a Mobile-Friendly Website: Responsive Design in CSS
  • What is Favicon.ico and How to Create a Favicon Icon for Your Website
  • Important Precautions to Take When Buying a Domain Proper name
  • How to Accept Credit Cards on Your Website
  • How to Annals Your Own Domain Name

New Articles

  • How to Ready the Meridian of a DIV Relative to a Browser Window (CSS)
  • How to Generate the Free Let's Encrypt SSL Document on Your Own (Windows) Computer
  • How to Insert Meta Tags into a Web Page with BlueGriffon
  • How to Play a Song (or Some Other Audio Prune) from a List on a Website
  • How to Describe a Horizontal Line on a Web Page with Expression Web
  • How to Create a Website Free of Accuse
  • Why Tin't I Make Up Whatever Domain I Want? Is There a Way to Do Abroad with a Registrar Birthday?
  • What's the Departure Between a Domain Name Registrar and a Web Host?
  • How to Brand a Mobile-Friendly Website: Responsive Blueprint in CSS
  • What's the Deviation Betwixt a Content Direction System (CMS), a Blog, a Web Editor and an Online Site Builder?

Popular Articles

  • How to Create a Blog
  • How to Make / Create a Website: The Beginner's A-Z Guide
  • Tips on Choosing a Skilful Domain Name
  • Expression Web Tutorial: How to Pattern a Website with Microsoft Expression Web
  • Dreamweaver Tutorial: How to Design a Website with Dreamweaver CS6
  • BlueGriffon Tutorial: How to Pattern a Website with BlueGriffon 3
  • How to Design and Publish Your Website with KompoZer (free WYSIWYG web editor)
  • Free Feedback/Contact Form Sorcerer

How to Link to This Folio

It volition appear on your page equally:

How to Create a Rectangular Box to Contain Your Text/Pictures with CSS


bullockantsmairming.blogspot.com

Source: https://www.thesitewizard.com/css/rectangular-box-border.shtml

0 Response to "Html Draw Box Around Div"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel