SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: noob: css CDATA

  1. #1
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    noob: css CDATA

    Here is the css content inside html:

    Code:
    <style type="text/css" title="defaultStyle">
    /*<![CDATA[*/
    <!--
    
    SOME CSS CONTENT
    
    -->
    /*]]>*/
    I took out "SOME CSS CONTENT", put it into a temp.css file.
    When link the css file like this:
    Code:
    <link rel="stylesheet" href="temp.css" type="text/css" />
    how and where do I put the:
    Code:
    /*<![CDATA[*/
    <!--
    
    and
    
    -->
    /*]]>*/

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    You don't need that code in the css file as it is only necessary when the css is embedded in the xhtml page.

    The only thing in a css file is the css and css comments /* etc */

  3. #3
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    noob: can you do this in css and html

    can you have this in css and in html?:

    In css file:
    Code:
    #center_html {
    	display: table;
    	overflow: visible;
    }
    
    #center_body {
    	background: #f0ffe1;
    	display: table-cell;
    	vertical-align: middle;
    }
    and in html file:

    Code:
    <html id="center_html" >
    
    <body id="center_body" >
    </body>
    </html>
    or

    In css:
    Code:
    #center html {
    	display: table;
    	overflow: visible;
    }
    
    #center body {
    	background: #f0ffe1;
    	display: table-cell;
    	vertical-align: middle;
    }
    in html file:

    Code:
    <div id="center">
    <html>
    <body>
    </body>
    </html>
    </div>

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    You can't put divs above the html tag as html is the root element. You should also know that display:table doesn't work in IE (all versions including ie7) so there is not much point in using it unless you just want to support other browsers.

    You will need to add a height and width of you want to vertically and horizontally center something.

    Code:
    html {
        display: table;
        overflow: visible;
        height:100&#37;;
        text-align:center;
        width:100%
    }
    
    body {
        background: #f0ffe1;
        display: table-cell;
        vertical-align: middle;
    }
    See the FAQ on vertical centering or have a look here.

  5. #5
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you...for taking the time to answer my questions.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,817
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Also you don't need ids on the html and body tag as there is only one of each so you can reference them by their tagnames of html and body without needing ids.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Wizard bronze trophy DaveWoods's Avatar
    Join Date
    Dec 2004
    Location
    Derbyshire - UK
    Posts
    2,651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    True in this case but there may be times when your CSS file is styling multiple pages in which case it's a common method of providing styles to a specific page by providing a unique ID on the body of individual pages.

    In this case though I completely agree with Stephen.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •