Alignment CSS properties

Alignment CSS properties: So far all our HTML elements have been in the same position on our page. The text-align and float CSS properties allow you to align (another way of saying position) text and other HTML elements on your page.

The text-align property lets you position your text to the left, right or centre of your page. Remember to use the American spelling “center” and include the hyphen ()

<body>
 <div style="text-align: center;">
 Hello world with alignment......
 </div>
 <p>Hello World without alignment.....</p>
</body>

Sample output of above code:

Hello world with alignment……

Hello World without alignment…..

We can also use CSS to position HTML elements, such as a

<div>

tags or images, to the left or right of the page. You use the float CSS property and set the value to the left or right.

<body>
 <div style="float: right;">
 The Hello world program:<br/>
 <img src="img3432.jpg" alt="The Hello world program"/>
 </div>
</body>

The text-align and float CSS properties are easy ways to create an interesting layout for your web page.


Related Posts:

How do I install plugins in WordPress?

WordPress Posts vs Pages

MORE CSS PROPERTIES

Introduction to Batch File Viruses

CODING WEB PAGES (HTML, CSS, & JavaScript)

CODING WITH CSS: The style attribute

Tips and tricks for USING THE DOM API

Tips and Tricks for WRITING JAVASCRIPT code

Where Kids Learn to Code.

Redirect New Registered Users to a Specific Page – WordPress

Build to-do list web-app with code

Using more than one CSS property

Building a web page with HTML tags

The color CSS property

 

Connected through code, Choose Your Platform!

About the Author: Bernard Aybout

In the land of bytes and bits, a father of three sits, With a heart for tech and coding kits, in IT he never quits. At Magna's door, he took his stance, in Canada's wide expanse, At Karmax Heavy Stamping - Cosma's dance, he gave his career a chance. With a passion deep for teaching code, to the young minds he showed, The path where digital seeds are sowed, in critical thinking mode. But alas, not all was bright and fair, at Magna's lair, oh despair, Harassment, intimidation, a chilling air, made the workplace hard to bear. Management's maze and morale's dip, made our hero's spirit flip, In a demoralizing grip, his well-being began to slip. So he bid adieu to Magna's scene, from the division not so serene, Yet in tech, his interest keen, continues to inspire and convene.