Solved

CSS DIV Border - inside rather than outside?

Posted on 2009-04-01
5
14,516 Views
Last Modified: 2012-05-06
I only care about IE7 (a proprietary / embedded web app). I know how to use javascript to change the border of a DIV on rollover, but the problem is that the border appears around the outside of the DIV. Is there a way to specify that the border should go around the inside only?  (like in Photoshop, the Stroke command, you can choose to stroke outside, inside or middle. )

Thanks!
0
Comment
Question by:PMH4514
5 Comments
 
LVL 23

Accepted Solution

by:
apresto earned 125 total points
Comment Utility
0
 
LVL 9

Expert Comment

by:knonie
Comment Utility
Each browser has its default behavior of displaying borders in HTML, either around div or table, and we cannot change it using CSS or any coding method, as far as I know.

There are no further settings like we have in PhotoShop.

If you feel that your div appears slightly bigger with this border, you can subtract that value from div's width.
e.g. Suppose you want to display a div of 100px width, but with 1px border around it is appearing as 102px, just use 98px width div.

:-)
0
 
LVL 12

Expert Comment

by:alien109
Comment Utility
side note - make sure you include a doctype decalration in your html, so that you persuade the browser (specifically IE) to render in standards mode. That way your size/border calculations will be consistent between browsers.
0
 

Author Comment

by:PMH4514
Comment Utility
which doctype specifically?

I was able to accomplish my needs by way of a standalone DIV that I set to the proper location/height/width etc based on mouse location. (the mouse moves over a grid of images and must "highlight" them with a box.  

Thanks!
0
 
LVL 12

Expert Comment

by:alien109
Comment Utility
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

should do the trick. however, i would always encourage strict xhtml :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now