The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Align Textbox?, not being able to align textbox
SpeedFreak
post Apr 16 2011, 02:50 PM
Post #1





Group: Members
Posts: 1
Joined: 16-April 11
Member No.: 14,345



Hi there, im new to html im only a kid, my problem is i have made a textbox using textarea and i have aligned the text within it, but im not sure if its possible to then align the actual text box itself to the middle of the webpage, i have so far:

<html>
<head>

<!-- Title -->

<title> Gamers United </title>

</head>
<body style="background-color:black;">

<!-- Title + Page -->

<h1 style="color:white;"><b><u> Gamers United </u></b></h1>
<h2 style="color:white;"><u> Home Page </u></h2>

<hr style="color:red;" />

<!-- Pages -->

<a href="HTML/Home Page.html">Home Page</a> &nbsp; <a href="HTML/About Us.html">About Us</a> &nbsp; <a href="HTML/Flash Games.html">Flash Games</a>

<hr style="color:red;" />

<p align=center style="color:red;font-size:50px;"><u> NEWS </u></p>

<br/>

<textarea style="text-align:center;border:0;background-color:black;color:white;" cols="40" rows="5"> News go here </textarea>

</body>
</html>

Im wondering if theres something i can put after Textarea in order to align my text box, thank you. :huh:
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 16 2011, 03:29 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



Please see:
http://dorward.me.uk/www/centre/
http://www.w3.org/Style/Examples/007/center.html

Note that textarea is supposed to be used for form input, not as a general display element.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
joyful
post Apr 16 2011, 06:08 PM
Post #3


Advanced Member
****

Group: Members
Posts: 239
Joined: 15-November 10
Member No.: 13,147



Hey,
You also could just add this tag before and after the textarea:
CODE

<center>

<textarea style="text-align:center;border:0;background-color:black;color:white;" cols="40" rows="5"> News go here </textarea>

</center>

But, as Darin showed you, there are better ways to do this:
You could center your whole body by adding this css:
CODE

<style type="text/css">
body {
    text-align: center;
}
</style>

Or you could put this in a div then center the div...
There are a lot of options.

Hope this is helpful!

--
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 17 2011, 01:52 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



While that works it's kinda old style. We have tried to get away form that kind of presentational HTML for some ten years now. It's better to leave things like that to CSS, for many reasons, and avoid to use deprecated markup like the center element and the center attribute along with FONT, colors, borders and so on. If you are learning, there's no reason to even learn how to use that stuff, you'll just struggle to unlearn it later. It's enough to know it's there and was once widely used so you recognize it when you see it and know what it is.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
joyful
post Apr 17 2011, 02:08 AM
Post #5


Advanced Member
****

Group: Members
Posts: 239
Joined: 15-November 10
Member No.: 13,147



Yes Pandy, that is true...
There are many other/better ways to do this with CSS... Such as:
If text:
CODE
.object {text-align: center;}

If div:
CODE
.object {margin-left: auto; margin-right: auto;}

And so on...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 29th March 2024 - 02:29 AM