Results 1 to 6 of 6

Thread: Need Help With CSS. Very Basic.

  1. #1
    Join Date
    May 2014

    Unhappy Need Help With CSS. Very Basic.

    Firstly let me apologise for such a nooby question.

    I have definitely learnt this but it has totally slipped my mind for some reason. I have a feeling I should use <div> tags?

    I have tried to use them and sadly it still hasn't worked. Here are my HTML and CSS codes:

    HTML Code:
    <!DOCTYPE html>
    				<title> My Family </title>
    				<link href="stylesheet.css" rel="stylesheet" type="text/css">
       	<img src="http://i.imgur.com/M3wjMqL.png"/> </h1>	
    	<p>As a starting point for my web development I have decided to build a site about my family. I plan to use this as a personal scrapbook, but if you enjoy it then that is a bonus.</p>
    	<img src="http://i.imgur.com/0Y27c6l.jpg" >


    h1 {
    font-size: 70px;
    font-family: Cursive;
    text-decoration: underline;
    color: #83A7CC;
    p  {
    font-size: 50px;
    font-family: Serif;
    color: #EFE3EF;
    *   {
    text-align: center;
    body {
    background-image: url("http://www.fabiovisentin.com/thumb.aspx?img=/photography/photo/25/sky-wallpaper-02939.jpg&w=1440&c=75");
    img   {
    height: 300px;
    width: 300px;
    border: 4px solid #EFE3EF;
    Please, excuse my newbisms.

  2. #2
    Join Date
    May 2014
    EDIT: Ignore the div tags. I realise they're in the wrong place. I forgot to remove them before posting this.

  3. #3
    Join Date
    May 2014
    EDIT of my EDIT: I fixed it:

    h1 img {

    border: none;
    height: 150px;
    width: 600px;

  4. #4
    Join Date
    Oct 2013
    A quick comment here. You backed yourself in a corner by applying the 300x300 size for the IMG tag. Now, for every image (jpeg,gif,png, et al) you ever put on any page on your site you'll be fighting that size just as you did for the image in your H1.

    You're better off using the IMG tag's height and width attributes. Yes, it's old-school straight HTML, but you can make each image the size it really needs to be. Ergo:
    HTML Code:
    <img src="http://i.imgur.com/M3wjMqL.png" width="600" height="150" alt="fill in this attribute!"/>
    ----- AND FURTHER DOWN -----
    <img src="http://i.imgur.com/0Y27c6l.jpg" width="300" height="300" alt="fill in this attribute!"/>
    In the CSS you can remove the new h1 img {...} stuff. Then remove the width and height stuff from the img declaration:

    img   {
    border: 4px solid #EFE3EF;
    And another hint : Learn to use CSS "classes". It will save you a lot of headaches later -- those headaches being caused by pounding your head on your desk saying, "why oh why did I make ALL my text centered, why oh why did I put a border around EVERY image?"
    Last edited by Kevin2; 05-30-2014 at 11:55 AM.

  5. #5
    Join Date
    May 2014
    Quote Originally Posted by Kevin2 View Post
    Thanks a million for the advice, man. I am doing it like this as this is the order so far I have learnt. Any advice will prove valuable in the future.

    Thanks again.

  6. #6
    Join Date
    Oct 2013
    Another hint: Always resize your images to fit what they will display at in the page. For example, the picture of your family (I assume?) is 926x960. The HTML resizes it to 300x300. That does not resize the actual image! It only determines how that image will display. The user then must download an oversized image -- a waste of time and bandwidth.

    Anyway, I sort of rebuilt your page's code (HTML & CSS) as shown below. Not perfect, but it validates and conforms to my above comments as well as some generally recognized "best practices". See notes in the code.

    HTML Code:
    <!DOCTYPE html>
     <html lang="en"> 
    		<meta charset="utf-8">
    		<title> My Family </title>
    		<link href="stylesheet.css" rel="stylesheet" type="text/css">
    	<body class="sky">
    	<header>	<!-- For validation purposes, an H1 cannot be just an image, hence this coding. -->
    		<h1 class="hidden">
    		The Barmy Army
    		<img src="http://i.imgur.com/M3wjMqL.png" width="600" height="150" alt="The Barmy Army">
    	<p class="largetext center">As a starting point for my web development I have decided to build a site about my family. I plan to use this as a personal scrapbook, but if you enjoy it then that is a bonus.</p>
    	<p class="center">
    		<img class="border" src="http://i.imgur.com/0Y27c6l.jpg" width="300" height="300" alt="family pic">
    And the CSS:
    h1 {
    font-size: 5em;			/* EM sized fonts scale better than pixel sizes (px) in different devices (think mobile and tablet). */
    font-family: sans-serif;	/* "Cursive" is not a font-family */
    /* text-decoration: underline; <-- DO NOT underline text! Links are underlined by default so this causes confusion! */
    color: #83A7CC;
    text-align: center;		/* H1 and H2 can be centered by default. H3 and H4 -- well, maybe. H5 and H6 definitely not; center if necessary using a class */
    h1.hidden  {		/* positions and sizes the H1 to hide it and make it not reposition other content */
    text-indent: -99999px;
    width: 1px;
    height: 1px;
    header  {
    text-align: center;
    .largetext  {
    font-size: 3em;		/* 3em approximates 50px on my screen. */
    font-family: Serif;
    color: #EFE3EF;
    .center   {
    text-align: center;
    .sky {
    background-image: url("http://www.fabiovisentin.com/thumb.aspx?img=/photography/photo/25/sky-wallpaper-02939.jpg&w=1440&c=75");
    .border  {    /* puts the border around your family photo -- or anything else needing it */
    border: 4px solid #EFE3EF;
    HTH, and good luck!

Thread Information

Users Browsing this Thread

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

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.09855 seconds
  • Memory Usage 2,901KB
  • Queries Executed 13 (?)
More Information
Template Usage (35):
  • (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
  • (3)bbcode_code
  • (3)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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 (70):
  • 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_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_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