I have some text and <span>
tag, which are inside a <div>
.
<span>
is float: right;
I need the text to be on the left side and <span>
on right side.
In every browser it displays perfectly except ie7
. How can I fix this bug?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title> Testing page</title>
</head>
<body>
<div style="border:2px solid #000; display:inline;">
welcome<span style="float:right"> demo</span>
</div>
</body>
</html>
Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side. float:right; This property is used for those elements(div) that will float on right side.
HTML float left is used to align content at the left alignment of the webpage or HTML document. Whenever Float left is used within code, it is responsible for putting contents on the left side of the container.
Span is an inline element, therefore having span inside span is valid.
move span before text, this should help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With