I have always had this problem making a css class work with a span
for example:
.cAlign{
text-align:center;
}
<span class = 'cAlign'>HTML: Chat name has already been taken; choose another name</span>
But this doesnot work in the code while a div works properly for the same css class in the same file.
Suggestions are welcome.
Undesired Behavior: <span>(Solved)
Moderator: General Moderators
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
Undesired Behavior: <span>(Solved)
Last edited by raghavan20 on Wed Aug 10, 2005 8:08 am, edited 1 time in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
a span is, unless otherwise defined, always the same dimensions as the content it holds. So trying to center in a span will do nothing unless you set it's dimensions larger than its content. A div on the otherhand is, unless otherwise defined, the size of its container thereby often being larger than its content and doing the alignment.
Divs are also block level, versus spans which are inline elements. All these attributes can be fiddled with in CSS, of course.
Divs are also block level, versus spans which are inline elements. All these attributes can be fiddled with in CSS, of course.
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
thanks for your answer.
I was trying with other code.
Now I have found the code for the span to work like div. Also works with float property.
I was trying with other code.
Code: Select all
<html>
<head>
<style type="text/css">
<!--
.cAlign {
text-align:center;
color:#CC3300;
background-color:#0000CC;
font-size:1.4em;
width:30%;
height:40;
float:left;
margin:5px;
}
-->
</style>
</head>
<body>
<span class="cAlign" style="">hi all</span>
<span class="cAlign" style="">hi everyone</span>
</body>
</html>