I have a problem, I want to add a border on my text with html, css or javascript. the size of the border should be 10px. Is this possible?
So it should be like this:
Hope you can help,
regards chris
I have a problem, I want to add a border on my text with html, css or javascript. the size of the border should be 10px. Is this possible?
So it should be like this:
Hope you can help,
regards chris
As said, you could try this with text-shadow
, but it is not recommended. I edited Ankit's solution, because it looked aliased:
http://jsfiddle.net/ZnfED/1409/
text-shadow: 2px 0 black, -2px 0 black, 0 2px black, 0 -2px black, 1px 1px black, -1px -1px black, -1px 1px black, 1px -1px black;
As Eric Brockman says, you could use text-stroke
, but this is currently not supported by most browsers. It works on -webkit-
prefixed browsers though.
Here's an example fiddle: http://jsfiddle.net/ZnfED/1410/
-webkit-text-fill-color: white;
-webkit-text-stroke-width: 2px;
-webkit-text-stroke-color: black;
Note that -webkit-text-fill-color
will always overwrite color
, no matter what the order is in your CSS.
You require lot of shadows, more the number of shadows better is the effect
{
font-size:80px;
color: green;
text-shadow: 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black;
}
Here is the link to demonstrate it: http://jsfiddle.net/ZnfED/1408/ you can increase/decrease the width of shadow by using any other value in text-shadow property (where i have used 4px)
NOTE : This is supported by only a few browsers
I'll suggest you to use image instead of this because you will not need to bother about browser compatibility
Try adding this to your style sheet:
h1 {
color: black;
-webkit-text-fill-color: white; /* Will override color (regardless of order) */
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: black;
}
Read more about this option here: http://css-tricks.com/adding-stroke-to-web-text/
Instead of relying on experimental features, I suggest you create a transparent .PNG image that looks like the one you've posted, create a div
with the necessary text and width, then set the text-indent
property to -9999px
in CSS. Set the PNG image as the background of the div
using the background property. and you will have successfully used the -9999px
hack.
See here: http://www.dennisplucinik.com/blog/2007/09/01/css-hack-text-indent-10000px/ This is what Apple uses to create beautiful typography on their website.