Results 1 to 3 of 3

Thread: [RESOLVED] CSS/Html - Attempting CSS

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,386

    Resolved [RESOLVED] CSS/Html - Attempting CSS

    I'm attempting to create a login page using CSS using an external css sheet. Here is my html code:
    Code:
    <!doctype html>
    <html>
    	<head>
    		<Title>EMP - Login</title>
    		<link rel="stylesheet" type="text/css" href="login.css">
    	</head>
    	
    	<body>
    		<h1>Login</h1>
    		<table id="user_and_pass">
    			<tr>
    				<td id="tbl_user">Username:</td>
    				<td id="tbl_user_txt"><input type="text", name="txt_user"></td>
    			</tr>
    			<tr>
    				<td id="tbl_pass">Password:</td>
    				<td id="tbl_pass_txt"><input type="text", name="txt_pass"></td>
    			</tr>
    			<tr>
    				<td id="tbl_casing">Passwords are case sensative.</td>
    			</tr>
    			<tr>
    				<td id="tbl_forgot"><a href="">Forgot your password?</a>
    				<td id="tbl_btn_login"><button name="btn_login">Login</button></td>
    			</tr>
    		</table>
    		
    		<table id="new_user">
    			<tr>
    				<td id="tbl_new_acc">Don't have an account?</td>
    			</tr>
    			<tr>
    				<td id="tbl_new_acc_btn"><button name="btn_new_account">Get one now</button></td>
    			</tr>
    			<tr>
    				<td id="tbl_easy">It's easy!</td>
    			</tr>
    		</table>
    
    </html>
    So far I'm only trying to format some of the td's:
    Code:
    #tbl_casing td
    {
    color:grey;
    margin-left:30px;
    margin-top:20px;
    font-size:14px;
    }
    But the formatting isn't showing up in my page. Am I presenting my css wrong?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: CSS/Html - Attempting CSS

    Using #tbl_casing td means the CSS is looking for the td under #tbl_casing.

    Since #tbl_casing is the td, it will never style it.

    What you could do is either

    Code:
    #tbl_casing
    {
    color:grey;
    margin-left:30px;
    margin-top:20px;
    font-size:14px;
    }
    Or

    Code:
    td#tbl_casing
    {
    color:grey;
    margin-left:30px;
    margin-top:20px;
    font-size:14px;
    }
    The first, would reference any element with the ID of #tbl_casuing, and the second would reference only tds with the ID of #tbl_casing.

    Although in these cases, it seems more likely you would want to use a class (.) rather than an ID (#), simply because this seems like something that could be used on multiple elements on the page. An ID should only appear once on a page.
    Last edited by kfcSmitty; Apr 2nd, 2013 at 01:06 PM.

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,386

    Re: CSS/Html - Attempting CSS

    Ahhh awesome. Thanks a lot, and by the way, I'm not so much a fan of your chicken ;]
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

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



Click Here to Expand Forum to Full Width