Page not picking up css class

Posted on 2008-11-12
Last Modified: 2012-05-05
Hi there I have an ASP.NET page in which I have various <div> tags controllling the layout of my controls.

My problem is that if I do the following:
<div align="left">

My divs are left aligned as I would expect them to be however I don't want to explicitly define the alignment as I may want to change it so instead I want to use a class so I can amend all tags in one place
so I have defined a class as follows:
then have my <div> tags look like <div class="myclass">blah</div> but this doesn't work.
Can anyone tell me how I define the alignment correctly in a css class.

Question by:Samm1502
    LVL 22

    Accepted Solution

      text-align: left;  

    LVL 4

    Expert Comment

    Your problem is simple, just do the following:
    in HTML:

    <div id='myCoolDiv'> </div>

    And in the css:
    #myCoolDiv{   border: 1px solid green;}

    That should do it.
    Here is the deal, when you use the class tag in HTML your css class must start with ".", in this example it would be .myCoolDiv and if you use id tag, then you use the #.

    Author Closing Comment

    This worked - many thanks

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now