Web Design Stuff
HTML Tutorials    CSS Tutorials    Web Hosting   Resources
Create a Web Page 101
Making Web Pages Intro What is a Web Page? Why Make a Web Page? The History of HTML Learn HTML or XHTML?
Basic HTML
Basic HTML Tutorials Basic HTML Necessities How to Make a Web Page How to Edit a Web Page The Basics of HTML Tags Basic HTML Page Structure HTML Attributes
HTML Font Codes
HTML Font Codes Intro HTML Font Color Codes HTML Font Size Codes HTML Font Style Codes HTML Bold/Italic Codes Combining Font Codes
Formatting Text
Formatting Text Intro Making Paragraphs Miscellaneous Formatting Headings & Subheadings Creating Hyperlinks
Using Graphics
Using Graphics on the Web Add Graphics to Your Pages Graphics and Accessibility How to Align Graphics Page Color & Background Graphics as Hyperlinks Horizontal Rules
Creating Tables
HTML Tables Tutorials HTML Table Fundamentals Background & Border Color Table Frames & Rules Table Width and Alignment Cells 1 -Space & Alignment Cells 2 -Row Column Span Cells 3 -Width & Height
Making Lists
HTML Lists Tutorials Bulleted Lists Numbered Lists Definition Lists
HTML Frames
HTML Frames Tutorials Using Frames for Layout Advanced Frame Layouts Putting Hyperlinks in Frames Frame Border Width Color, Margin and Control Problems with Frames SmartFrames: A Solution SSI: An Alternative to Frames
Web Page Forms
Making Feedback Forms A Simple Feedback Form Installing NMS FormMail Debugging Your Setup My Web Host is Out to Lunch User Input Components Text Fields Checkboxes & Radio Buttons Dropdown Menus Push Buttons Layout and Presentation
Basic CSS
Basic CSS Tutorials What is CSS? Why You Should Use CSS How to Use CSS Inline Styles Embedded Style Sheets External Style Sheets Class Selectors ID Selectors Combining Selectors
CSS Properties
CSS Properties Intro Font Styles Width, Height & Spacing Borders Backgrounds Position Float & Alignment Hyperlinks
All About Web Hosting
Hosting Your Own Website What is a Web Host? Your Website's Home Page Building a Website Offline About Free Web Hosting Best Free Web Hosting Commercial Web Hosting How to Get a Domain Name Ecommerce Web Hosting Web Hosting Terminology
Free Web Design Tools
Best Free Website Tools Best Free Text Editors Best Free Graphics Editors Free Website Analysis Tools
Setting Up HTML Kit
HTML Kit Introduction How to install HTML Kit Screenshot Breakdown Basic Configuration Overall Appearance Shortcuts and Startup Editing Window Customizing Toolbars Using the Favorites Tab Making a New Actions Bar Odds and Ends
Free Templates
Free Website Templates Two Column Fixed Width Three Column Liquid Layout Miscellaneous Templates Dynamic Menu Effects Two Column Experimental Terms of Use About These Templates
Website Templates Help
Getting Started Template Zip File Download How to Edit Your Template What to Edit in the HTML How to Add Your Logo Making a Website
Web Design Tips
Web Design Basics Tables vs. Tableless Using Tables for Layout Example Table Layouts World's Crappiest Web Page
Twitter Backgrounds
Twitter Backgrounds Intro Cool Twitter Backgrounds Cool Twitter Backgrounds 2 Plain Twitter Backgrounds Dark Twitter Backgrounds Best Twitter Backgrounds Cute Twitter Backgrounds Music Twitter Backgrounds Music Twitter Backgrounds 2 Twitter Backgrounds 101 TERMS OF USE
All About Web Browsers
What is a Web Browser? Mozilla Firefox Internet Explorer Opera How to Set Up Firefox Top 5 Firefox Extensions
 
Contact
Post Some Feedback Send Me An Email Iron Spider Blog About Iron Spider... Site Conventions
 
 
 

 

CSS Properties - Borders

 
The CSS properties in the table below are all shorthand properties that can be used to define the borders on various components on your web page. These properties are typically applied to block elements but you can also apply them to images and some form elements. These include the following:

body, p, div, blockquote, table, td, ul, ol, li, form, input, textarea, select, img


CSS Properties List 3 - Borders
Property NameSome Possible ValuesWhat It Does
border1px solid blackDefines all borders
border-top1px solid blackDefines top border
border-bottom1px solid blackDefines bottom border
border-left1px solid blackDefines left border
border-right1px solid blackDefines right border


NOTES:
  • Pixels (px) ~ This sets the thickness of the border in pixels. The syntax is any number followed by px.

    Example: border: 1px solid;

    There are other measurements you can use to define the thickness of borders but personally I think it's best to use pixels to maintain a tight control on how your web page looks. (More about pixels...)
  • Border
    Border-top
    Border-bottom
    Border-left
    Border-right


    These are all shorthand CSS properties, i.e., they allow you to apply several different values to a kind of 'all-purpose' property thus saving space and time.

    For example, if it were written in 'longhand', you could conceivably be writing twelve different style declarations to apply width, style and color to all four borders of a block element. The following example will illustrate:


    DIV {
       border-top-width: 1px;
       border-bottom-width: 1px;
       border-left-width: 1px;
       border-right-width: 1px;
       border-top-style: solid;
       border-bottom-style: solid;
       border-left-style: solid;
       border-right-style: solid;
       border-top-color: black;
       border-bottom-color: black;
       border-left-color: black;
       border-right-color: black;
    }



    DIV {
       border: 1px solid black;
    }


     

    Click on the buttons above to see the difference between writing CSS longhand and CSS shorthand. Both of the above examples will produce the exact same result.

    Using the properties border and border-top as examples, the shorthand syntax is written as follows:

    border: width style color;
    border-top: width style color;

    OR just simply...

    border: width style;
    border-top: width style;

    In the above:

    1. width = Any CSS measurement but it's easiest to use pixels - e.g., 1px
    2. style = Any one of the following:

      • none - No border. Same as setting the border-width to 0px.
      • dotted - The border is drawn as a series of dots.
      • dashed - The border is drawn as a series of dashes.
      • solid - The border is drawn as a solid line.
      • double - The border is drawn as two solid lines.
      • groove - The border appears carved into the canvas.
      • ridge - The opposite of 'groove': the border appears as though it were coming out of the canvas.
      • inset - The border is drawn to apply a 3D inset appearance to the block element.
      • outset - The opposite of 'inset': The border is drawn to apply a 3D outset appearance to the block element.
      (NOTE: When style is omitted, the border style defaults to none. Hence if you want to actually create a border, it is necessary to declare style [and width if you don't want to use browser defaults (usually around 2 pixels)]. Values declaring color may be omitted.)
    3. color = Any named color or hexadecimal color code, e.g., red, green, blue, #ffffcc, etc. (Please see font color for more about what colors you can use for any HTML or CSS code.)
      (NOTE: When color is omitted, the border is rendered in the same color as the element's defined or inherited color. (See Font Styles properties for more information about the color property.)
EXAMPLES:

Here's an example of an inline style applied to a paragraph tag using some of the CSS properties described in the table above:


Example 1 - INLINE STYLE

<p style="border: 3px double red;">How now brown cow</p>



OR...

The same thing could be declared as an embedded stylesheet in the document head:


Example 2 - EMBEDDED STYLE SHEET

<style type="text/css">
<!--
p {
   border: 3px double red;
}
-->
</style>



...and in the document body, you would simply put this:


<p>How now brown cow</p>



Both Example 1 and Example 2 will produce the following effect:

How now brown cow



*   *   *


And to complement your ability to draw borders on block elements, you'll want to learn how to apply backgrounds...






Best Free Stuff
for webmasters

Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates

See also:

Best Free Web Hosting
How to Make a Web Page

 

If you need a .COM web address, you can get one quick and easy at...

www.GoDaddy.com
<~ BACK TOP NEXT ~>
 
HTML Tutorials |  CSS Tutorials |  Web Hosting |  Domain Names |  Web Design Resources
Iron Spider © Copyright 2004-2011 Robert Darrell