 |
BOOK: Beginning HTML, XHTML, CSS, and JavaScript  | This is the forum to discuss the Wrox book Beginning HTML, XHTML, CSS, and JavaScript by Jon Duckett; ISBN: 978-0-470-54070-1 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning HTML, XHTML, CSS, and JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 4th, 2010, 05:28 PM
|
|
Registered User
|
|
Join Date: Apr 2010
Posts: 70
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
How do you create borders around text?
The title says it all. Is there any way to add a border around a few words?
|
|

April 4th, 2010, 05:39 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
|
|
Code:
<html>
<head>
<style>
span.text-with-border {
border-style: outset;
border-width: 1px;
border-color:red;
}
</style>
</head>
<body>
Hello <span class="text-with-border">world</span>!
</table>
</body>
</html>
|
|
The Following User Says Thank You to PeterPeiGuo For This Useful Post:
|
|
|

April 4th, 2010, 05:42 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
|
|
Another example with more flexibility demonstrated:
Code:
<html>
<head>
<style>
span.tea-cup {
border-style: none solid solid solid;
border-width: 1px;
border-color:red;
}
</style>
</head>
<body>
A cup of <span class="tea-cup">tea</span>!
</table>
</body>
</html>
|
|

April 4th, 2010, 06:08 PM
|
|
Registered User
|
|
Join Date: Apr 2010
Posts: 70
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Thanks so much!
One more question - I have a long list. It is ordered using the alphabet, and i think it goes until H, so as you can see, it's a long list. If I want to place a border around it, would I use the span element, or the div element, or something else?
And must I use the span/div element, or can I use a different element. For example: Can I make everything in bold have a border simply by using the bold element in a CSS style sheet?
|
|

April 4th, 2010, 06:17 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
|
|
One way is, like you said, use div. You can also use ol, ul, li, and all three are defined in HTML 4.01 specification.
Code:
<html>
<head>
<style>
ol {
border-style: solid;
border-width: 1px;
border-color:red;
width: 40%
}
li {
list-style: upper-alpha;
}
</style>
</head>
<body>
<ol>
<li>Apple</li>
<li>Orange</li>
<li>Banana</li>
<li>Pear</li>
</ol>
</body>
</html>
|
|

April 4th, 2010, 06:21 PM
|
|
Registered User
|
|
Join Date: Apr 2010
Posts: 70
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by PeterPeiGuo
One way is, like you said, use div. You can also use ol, ul, li, and all three are defined in HTML 4.01 specification.
Code:
<html>
<head>
<style>
ol {
border-style: solid;
border-width: 1px;
border-color:red;
width: 40%
}
li {
list-style: upper-alpha;
}
</style>
</head>
<body>
<ol>
<li>Apple</li>
<li>Orange</li>
<li>Banana</li>
<li>Pear</li>
</ol>
</body>
</html>
|
I tried that, and it didn't work. But I"ll try again.
|
|

April 4th, 2010, 06:25 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
|
|
Difference between browsers...
Last edited by PeterPeiGuo; April 4th, 2010 at 06:40 PM..
|
|

April 4th, 2010, 06:39 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
|
|
The following works for IE8, Firefox, Opera, Safari and Chrome:
Code:
<html>
<head>
<style>
ol {
border-style: solid;
border-width: 1px;
border-color:red;
list-style: upper-alpha;
list-style-position: inside;
}
</style>
</head>
<body>
<ol>
<li>Apple</li>
<li>Orange</li>
<li>Banana</li>
<li>Pear</li>
</ol>
</body>
</html>
|
|

April 4th, 2010, 07:12 PM
|
|
Registered User
|
|
Join Date: Apr 2010
Posts: 70
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by PeterPeiGuo
The following works for IE8, Firefox, Opera, Safari and Chrome:
Code:
<html>
<head>
<style>
ol {
border-style: solid;
border-width: 1px;
border-color:red;
list-style: upper-alpha;
list-style-position: inside;
}
</style>
</head>
<body>
<ol>
<li>Apple</li>
<li>Orange</li>
<li>Banana</li>
<li>Pear</li>
</ol>
</body>
</html>
|
Ok I have IE. I'll try that.
|
|
 |