Results 1 to 4 of 4

Thread: Problem with only some of css file being linked to html file

  1. #1
    Join Date
    Jul 2012
    Vantaa, Finland

    Problem with only some of css file being linked to html file

    I have built a website (at long last). Whilst developing it I included the css code at the top of each html file. I am now trying to transfer the css code to it's own file and linking the html file to it.

    My problem is that the link works for the menus but not for the rest of the file. It looks like only the html file is displayed because text boxes and positioning etc are missing.

    My link is set up in the head section; <link rel="stylesheet" type="text/css" href="menu.css"/>

    The css file can be read here

    The website page used with the css is here

    If you click on books in the main nav bar you will see what the layout should look like.

    I've not done any css or html coding before. Can someone say what I need to do to get the page to display like the book page? The book page has the html in the head section.

  2. #2
    Join Date
    Aug 2012
    Lets see the HTML as well please.

    How are you declaring these selectors in your CSS? for example the names like "texted_5", "book_2", etc.

    You are not declaring them right. You are using selectors like they are elements, which they are not elements.
    You should be using Classes or ID's in your HTML file.

    For Example:

    <div class="book_2">
    <!--Some HTML inside a DIV named book_2-->

    That is what the html would look like.
    In the CSS for that same html, it would look like this:

    .book_2 {
    property: 20px;
    etc: 30px;

    If you were using ID's, you would have to use # instead of a period in front of the slector name in your CSS file.

    an ID would look like this:
    <div id="book_2">
    <!--Some HTML inside a DIV named book_2-->

    The css for that would look similar to the class one, but with a small change.
    #book_2 {
    property: 20px;
    etc: 30px;

    Also, consider running your CSS file through csslisible.com/?lang=en
    It will format it so its easier to read and navigate.
    You start off with spacing, but a quarter of the way through you drop the spacing.
    It just makes things more organized. Its a great tool.

  3. #3
    Join Date
    Aug 2012
    I fixed the top part of your CSS file so you could see what I mean. You were declaring each ID name, like they were elements.
    [Elements are the HTML name elements like "h1, h2, h3, body", etc. Even title and head, (which isn't actually style-able)]

    So since you are mostly using ID's to declare selectors, you must add # to your selectors, otherwise you are declaring elements...

    body {
        width: 1000px;
        margin: 0 auto;
        padding-bottom: 90px;
        background-color: #c0c0c0;
    #title {
        width: 1000px;
        padding-top: 3px;
        padding-bottom: 5px;
        text-align: center;
        background-color: #fffff0;
    #title h1 {
        text-align: center;
        font-family: verdana;
        color: #000;
    #title h2 {
        text-align: center;
        font-family: arial;
        color: #1107c7;
    #head-photo {
        width: 1000px;
    #menu ul {
        margin: 5;
        padding: 5;
        font-size: 1.5em;
        list-style: none;
    #menu ul li {
        display: block;
        float: left;
        position: relative;
    #menu li ul {
        display: none;
    #menu ul li a {
        display: block;
        margin-left: 5px;
        padding: 5px 10px;
        border-top: 1px solid #fff;
        text-decoration: none;
        white-space: nowrap;
        color: #1107c7;
        background: #fffff0;
    #menu ul li a:hover {
        background: #fffff0;
    #menu li:hover ul {
        display: block;
        position: absolute;
    #menu li:hover li {
        z-index: 200;
        float: none;
        font-size: 0.5em;
    #menu li:hover a {
        background: #ff7f50;
    #menu li:hover li a:hover {
        background: #fffff0;

    Also I noticed the selector RIGHT AFTER the end of the code I finished for you.

    main-box {
    h3 {
        width: 1000px;
        text-align: center;
        color: black;
        background-color: #fff;
    This is incorrect. Because you used:
    main-box { 
    h3 { 
    You used the squiggly brackets inside of already using them. Which isnt possible in CSS, so it would break the style.

    If you are declaring a style for the h3 element inside of the div id main-box you must write it like this:
    #main-box h3{ }
    That will apply your properties to all the H3 elements inside of the #main-box div, and only those. No other h3 outside of #main-box will not be effected.

    So remember if you want to style all the h1-h6 elements in the page, and not seperately, you could just use
    h3 { }
    Also notice that h3 doesnt have a " . " or a " # " in front of it. Because it is not a Class nor an ID. It is an HTML element. Elements dont need anything in front of them.

    Remember it is the best practice not to over declare selectors.
    For example you declared a selector similar to this:
    #title ul li a { }
    When you just remove the ul or li like this:
    #title li a { }
    Also take into account when you specify a style like the above example, you are targeting only one something very small in the whole HTML file.
    Maybe you want to style all the anchor elements inside of a list, and not just the anchors inside of the list in the div ID title.
    You could just use:
    ul a { }
    and that will style all the of links in a list with that style, instead of styling everything one by one.

    Hopefully all of this helped a bit to understand. Let me know if you need anymore help, or for me to further explain something better.

    By the way I recommend downloading both "Sublime Text 2", and "Aptana Studio 3"
    Sublime text is smaller, and can be used portable. I love it. It is really nice. But it is mainly just an Editor. It is free for an evaluation period and there is not an enforced limit of usage at this time. So you can use it and evaluate it as long as you would like at this time.
    Aptana Studio is Open Source and free. It is not just an editor, it is an IDE. (integrated development environment) So when you copy and paste or open your CSS file in aptana studio, it will show you all the mistakes you made as you make them. It helps sometimes when you cant figure out where in your code you messed up.
    Also if you start a project, you can open both your HTML file and matching CSS file and it will already know what the right ID and Class and Element selectors you are using in your HTML so it will know which you can use in your CSS file.
    I highly recommend it, especially for this issue.

    And to understand how to correctly declare all types of selectors in CSS, have a look at this page so you can fully understand.
    Last edited by CDev; 09-24-2012 at 09:39 AM. Reason: added a bit of content.

  4. #4
    Join Date
    Jul 2012
    Vantaa, Finland

    thanks for your help.

    Thanks for your help.

    The problem for me is that I bought a book that teaches html and supposedly css but it doesn't explain what the code does or why you need to set it out the way that they show. In reality the css is just coding examples with no explanations as to what the code does.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11173 seconds
  • Memory Usage 2,880KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (8)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates