954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Half text left aligned and half right aligned in a single paragragh

I have a some words that I want display in the footer, I want 2 words to be left aligned and rest to be right aligned.

I have my code something like this:

<div class="footer">
    MyWebsite             <!--This should be left aligned-->

    <!--Things below should be right aligned-->
    <a href="">Contact Me</a>
    <a href="">Help</a>
    
</div>


I want it to be displayed in a single line not to distribute in two different lines. Any way to do this by Html/css?

warlord902
Junior Poster
120 posts since Dec 2010
Reputation Points: 19
Solved Threads: 0
 
jalarie
Light Poster
40 posts since Mar 2006
Reputation Points: 10
Solved Threads: 5
 
<html>
</head>
	<style type="text/css">
	.footer{
	width:600px;background:#e3eeff;border:1px solid orange;
	}
</style>
</head>

<body>

<div class="footer">
<div style="float:left;">MyWebsite</span> <!--This should be left 

aligned-->

<!--Things below should be right aligned-->
<div style="float:right;">
<a href="">Contact Me</a>
<a href="">Help</a>
</div>

</div> 
</body>
</html>
tqmd1
Junior Poster
151 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 

Thanks jalarie and tqmd1 both works for me. But I preferred method given by jalarie as it allows me to use span tag within other html tags but when I do so with div it gives error. Also tqmd1, the code written by you contain 2-3 errors.

Anyways, thanks a lot guys :)

warlord902
Junior Poster
120 posts since Dec 2010
Reputation Points: 19
Solved Threads: 0
 

Please tell us what errors you facing there.
Let us try to sort out.

tqmd1
Junior Poster
151 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 
Please tell us what errors you facing there. Let us try to sort out.

It is when if I write something like this:

<div class="footer">
    <p>
        <div style="float:left">
            Hello World
        </div>
    </p>   <!-- this closing tag will give error that it cannot find starting <p> tag -->
</div>
warlord902
Junior Poster
120 posts since Dec 2010
Reputation Points: 19
Solved Threads: 0
 

It works fine for me here in IE8.
What browser you are using?

tqmd1
Junior Poster
151 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 
It works fine for me here in IE8. What browser you are using?

It may be working fine, but coding in Netbeans it show it as a error. So I think, may be it is not the standard way to code. Not sure

warlord902
Junior Poster
120 posts since Dec 2010
Reputation Points: 19
Solved Threads: 0
 

You can not properly put a "div" tag within a "p" tag. The "p" is in-line but the "div" is block level. IE sometimes gives a good result for bad code.

jalarie
Light Poster
40 posts since Mar 2006
Reputation Points: 10
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: