Styles or not to styles?

Scenario is as follows:

I use align="center" in a DIV tag to, well, align content to the center.  But when running the page I get a warning saying that align is outdated.  So I'm thinking that styles is a better way to go.

I remove align from the DIV tag and go for the equivalent style in styles - something like: styles="text-align: center;" - don't remember the exact format now but then I use Web Deveoper to set styles so it should be no syntax error.

Anyway, running the page in Internet Explorer 8 and I get no center align what so ever.  It's like IE8 have no idea what to do with styles in a DIV tag.  Using the old fashion align only and IE8 displays the page correctly.  The worst part is that Google Chrome does know exactly what styles="text-align: center;" is supposed to look like.  How is it possible that the very new release of IE don't know this essential information?

Anybody else seen this behaviour in IE8?

, MacGoose

0
MacGoose
4/25/2009 6:51:31 PM
asp.net.client-side 24353 articles. 1 followers. Follow

8 Replies
1002 Views

Similar Articles

[PageSpeed] 26

This works in IE7, IE8, F3 and Chrome, what are your trying to center in the div tag?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>text-align test</title>
</head>
<body>
    <div style="text-align: center;">
        center
        <div style="text-align: left;">left</div>
        <div style="text-align: right;">right</div>
    </div>
</body>
</html>
 
- William

Please mark the most helpful reply/replies as "Answer".

Give some of my PWSK modules a try.
0
whighfield
4/25/2009 7:19:15 PM
I'm actually trying to center a TABLE that I use for my page layout.  I have noticed that text do align correctly, but how do I then manage to center a TABLE?  Because even the TABLE shows correctly centered in the Design view of Microsoft Viusual Web Developer, but not in any other browser...

Thanx!

, MacGoose
0
MacGoose
4/25/2009 10:42:39 PM

             <table style="width: 50%; margin-left: auto; margin-right: auto;">

 

Like this perhaps?


-Chuck

Nullum gratuitum prandium
0
cyoung311
4/26/2009 2:45:40 AM
To center a block element you should use both left and right margins set to auto: style="margin:0 auto">.


If you would want to align text inside the table then use text-align property: style="text-align:center".

Hope that helps, Dasha
0
dashasalo
4/26/2009 6:30:53 AM
Thanx!

That actually works for center alignment.  But now another problem arise.  I used valign="top" to align a table to the top.  Now if I use styles to align to the top like: margin: 0px auto auto auto;  This is just like setting everything to auto.  Specifying a absolute alignment is impossible if the opposite is auto...

, MacGoose
0
MacGoose
4/27/2009 6:40:37 AM

 Dashasalo used some shorthand on her notation of the margin style; "margin: 0 auto;" says set the top margin to "0", the right margin to "auto", the bottom margin to "0" and the left margin to "auto".  It could also be written as "margin: 0 auto 0 auto;" or to be very specific "margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto;".  So in your case I'd specify "margin-right: auto; margin-left: auto;".


-Chuck

Nullum gratuitum prandium
0
cyoung311
4/27/2009 7:49:50 PM
That won't help me when I need a top-margin of 0px.  I have a TABLE inside another TABLE and I need the second TABLE to be aligned to the top of the first TABLE.  The only thing that I've found to work is to use the valign="top" on the TD that contains the second TABLE.  Any margin styles, be it: "margin: 0px auto 0px auto", or: "margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto;" will not allow my second TABLE to be aligned to the top - only valign="top" will...
0
MacGoose
4/27/2009 8:34:05 PM

 Well, OK.  Then how about trying the "border-collapse: collapse;" style?


-Chuck

Nullum gratuitum prandium
0
cyoung311
4/27/2009 8:52:34 PM
Reply:

Similar Artilces:

Client Side Button Styles
I have a question concerning styling HTML buttons in asp.net 2.0.I've created a simple Stylesheet called StyleSheet.css like this:----------------------------------------buttons{font-size: x-small;color: #ffffff;font-family: Verdana, Arial;background-color: #666699;}----------------------------------------And I have a button in an aspx page that I need to apply the style to, so I tried this:---------------------------------------------------------------------------------------------<link rel="stylesheet" type="text/css" href="Styles/StyleSheet.css" /><input type=button id="btnUpdate...

Style attributes updates on client side
Hello,I have some controls in an update panel. When I set style (display, fontWeight, etc) of these controls through client-side it does reflect in the browser. But when server-side control fires an event it still sees the old style attribute value.How do I communicate this?Example:Update panel U1 has DIV1 and LINK1 both with runat="server" attribute. DIV1 is display:none when page loads. LINK1 basically toggles DIV1 by setting display attribute (none/block) on server-side.But when I set DIV1 display property from client-side (say any other element) and after that I click LINK1, th...

Change page style client side
Like on http://www.yahoo.com/ I want to have different themes on my site. With a single mouseclick a user should be able to alter the page layout (without posting back).Therefore I want to change the class of certain divs on my page. But the id's of these divs are different on all pages.e.g. on the friends  page they are:<div id="friends" class="layout_red"></div><div id="overview" class="layout_red"></div>etc. I dont want to have javascript that differs on each page.What I want is: a cookie that determines which color ...

How can I reset the style of GridView from client-side....????
Hello: I've already changed the style this way:1 protected void dgViewSelectedItems_RowDataBound(object sender, GridViewRowEventArgs e) 2 { 3 if (e.Row.RowIndex > -1) 4 { 5 e.Row.Attributes.Add("onclick", "return rowClick(this," + e.Row.RowIndex + ")"); 6 } 7 } 8 9 protected override void Render(HtmlTextWriter writer) 10 { 11 string script = @"function rowClick(row, rowIndx) 12 { 13 ...

Good style or bad style?
With these declarations... type TItem = class Value : integer; constructor Create(aValue : integer); end; TItemList = class(TObjectList<TItem>) function A(anItem : TItem) : TItemList; end; procedure Q(L : TItemList); begin ... L.Free; end; ....we can write this: procedure P; begin Q(TItemList.Create .A(TItem.Create(1)) .A(TItem.Create(2)) .A(TItem.Create(3)) ); end; Is it ''good'' style or ''bad'' style ;-) Chris Christian wrote: ...

style
Name: tom Product: Firefox Release Candidate Summary: style Comments: I think the main icons on the new firefox 3.0 look i little bit cheap, like internet explorer. And that is 1 of the reasons i use firefox in stead of internet explorer Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9) Gecko/2008051206 Firefox/3.0 From URL: http://hendrix.mozilla.org/ ...

Style
Hi, Is it possible to change the foreground/background of some words from a text from a TextCtrl control without re-writing the whole text? I am thinking to change the background of the words which I move the mouse cursor over, but if I would need to re-write the whole text, I think the text might flicker if the user will move the mouse very fast... Thanks. Octavian ...

Style
Name: Tealsteam Email: tealsteam_at_hotmail.com Product: Minefield Summary: Style Comments: i like the new GUI on the tab bar it seems to help me alot as i do alot of design work, and comunity work for online gaming, so i have to switch between sites all the time, also the new spell checker works well as it helped me to peice this detailed comment together with correct spellings, and well the choices on the search bar between google, yahoo ect, is pretty neat as i can say this is a really nice beta, just 1 thing i was thinking about last night, lets say your on a page and you hit ...

style
    HI I want to show the following  in HTML page  What can be the style . Please help REgardsKaran RegardsKaran GuptaFor .net,Javascript and Sql server articles and interview question visithttp://guptakaran21.googlepages.com/main You will need to use pseudo-selectors. See this example: http://www.w3schools.com/CSS/tryit.asp?filename=trycss_firstletter  There are various ways to do this. Have a look here:http://www.mandarindesign.com/dropcaps.html  ...

Style
Name: Gabriel Rheault Email: leirbag666atgmaildotcom Product: Firefox Summary: Style Comments: I think that the style of firefox could be better, but for everythinf else, Good job Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3 ...

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Convert HTML styles to style objects ?
I have looked and looked but cannot find any code that will convert an HTML or CSS style to a Style object (System.Web.UI.WebControls.Style)I have a database that contains thousands of user-defined styles that need to be converted to style objects to be used on the server side.I am currently trying to write a conversion but the list of individual things to convert is growing and growing.Does anyone have an easy method?ThanksMatRegardsMatthew ...

CSS style
Hi,I have this link on a web page.  <A class="LinkStyle" href="">Some Text</A>The link was displayed correctly, like what I specified under 'LinkStyle'. I added a reference to an external CSS file, we have no control over this. This file has a generic style for links, like this a:link, a:visited, a:active, a:hover { text-decoration: underline; color: #123456; }And this is screwing up the 'Some Text' link. If I save this external css file locally and comment out the generic anchor styles, that fixes my problem. (I don't have acc...

Web resources about - Styles or not to styles? - asp.net.client-side

The Elements of Typographic Style - Wikipedia, the free encyclopedia
The Elements of Typographic Style is a book by Canadian typographer , poet and translator Robert Bringhurst . Originally published in 1992 by ...

Jumpers, snow and roast dinner: why do we celebrate Christmas winter-style?
Many Christmas traditions incorporated into the Australian festive season come from the northern hemisphere where children play in the snow and ...

Four teens charged over gang-style slaying in Montgomery County, US
Police say they stabbed their victim over and over, including in the back, before dumping his body in a ready-made grave. And they are barely ...

'British-Style' Broadway Club to Open at Renovated Hudson Theatre
... will reopen and operate Broadway's historic Hudson Theatre. Now, according to The Wall Street Journal , ATG plans to open a "British-style ...

Christmas: Celebrity style
Taylor Swift, Nicki Minaj, Kim Kardashian and other celebs share how they spent the holiday

IDG Contributor Network: Counting down to the holidays Unix-style
Counting down to the holidays Unix-style Counting down the days until Christmas or the beginning of Kwanzaa? Your Unix system can help with that. ...

Klay on Warriors' style: 'If we have to grind it out, we will'
... form Search 47° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Klay on Warriors' style: ...

One Direction's Harry Styles To Star In 'Scream Queens' Season 2?
"Scream Queens" star Lea Michele told One Direction fans to keep their cool if Harry Styles ends up starring in the potential season 2 of the ...

Harry Styles Coming to 'Scream Queens?' Lea Michele Says It May Happen
Harry Styles Coming to 'Scream Queens?' Lea Michele Says It May Happen

Premium iPhone 6S Protection With Spirited, Subtle Style
It's probably a fair guess after the festive gifts have been unwrapped that there are a lot more smartphones in use this weekend compared to ...

Resources last updated: 12/28/2015 12:42:12 AM