You must Sign In to post a response.
  • Category: ASP.NET

    CSS code call on page but not call on External Site

    If I put Inline code then it is working but if i am calling style sheet then it is not working. How i can fix it. Code is given.

    body {
    margin: 0px;
    background-image: url(../images/back_strip.jpg) ;
    background-repeat: repeat-x ;
    background-color: #E4F7F9 ;
    }.graytxt {
    font-family: Arial;
    font-size: 12px;
    font-weight: bold;
    color: #636363 ;
    }
    .txtbox {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    border: 1px solid #97C7C5;
    }
  • #768005
    HI,

    Make sure you're linking to your stylesheet using a link tag in the head of the HTML document.

    Suppose you have like:





    This is just a shot in the dark as (at the time of this post) you haven't provided source code.

    Make sure you're linking to your stylesheet using a link tag in the head of the HTML document.

    If you had:
    <style type="text/css">
    /* <![CDATA[ */
    #someid
    {
    margin: 0;
    padding: 3px 12px;
    }
    /* ]]> */
    </style>



    Then you need to have like


    #someid
    {
    margin: 0;
    padding: 3px 12px;
    }


    Then add this in the CSS file,

    <link rel="stylesheet" type="text/css" href="path/to/style.css" />


    There are also some common mistakes which people usually do.

    Some common newbie mistakes include:
    * <style type="text/css" src="path/to/style.css">: because it's a similar syntax to the <script> tag, which would make sense, but is invalid
    * <link rel="stylesheet" src="path/to/style.css">: but link elements use href not src
    * placing link elements within the body: although browsers will tend to manage link elements in the body, there are likely going to be some errors, and it's not a defined behavior
    * not specifying a doctype declaration: allows the browser to go into quirks mode, which is never a good idea.

    Thanks,
    Mani

  • #768015
    Hi Nitin.

    As you said properties are working when you have written inline css styles.
    So it will work even if you group all your css properties in to style.css and refer this css file in the aspx , cshtml or html file where you need. Just drag the css file and drop in the necessary html or aspx page it will work.

    <link href="Content/Site.css" rel="stylesheet" />

    In above line I have refered site.css in my aspx page. site.css is present in the Content folder of my project.
    It is good to place the reference in the head section.
    Hope it will help you. If any issue let me know.

    Sridhar Thota.
    Editor: DNS Forum.


  • Sign In to post your comments