₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,345,397 members, 8,517,234 topics. Date: Thursday, 12 November 2026 at 04:35 AM

Toggle theme

Having Problems With Css And Doctype Declaration - Webmasters - Nairaland

Nairaland Forum › Science/Technology › Webmasters › Having Problems With Css And Doctype Declaration (709 Views)

1 Reply

Having Problems With Css And Doctype Declaration by Ajax1211(op): 7:42am On Jul 27, 2013
Am creating my first website and I realise that my css codes don't work properly when I include a doctype declaration to the html page.

Don't know what the problem is, the css works fine but the doctype changes everything.

And also need help on the specific css codes to use for crossbrowser compatibility.

A brother needs help, thanks.
Re: Having Problems With Css And Doctype Declaration by GraphicsPlus(m): 8:42am On Jul 27, 2013
Am not sure what you really mean. Css has nothing to do with doctype. Doctype is strictly for html. Maybe, you are missing out something that relates to your stylesheet. Instead of using html4 doctype that has lots of confusing and cluttered details, you can start using html5 doctype, which is short and clean. And one good thing about html5 doctype is that you can still declare it and still use old html4 tags and elements and you will still be good to go.

Add these lines of codes at the beginning of your html document.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
</head>


What do you mean by browser compatibility? If you are using html4 and css2, then you should not worry yourself about browser compatibility because even ie7 understands all the html4 and css2 properties and values.

But if you are using html5 and css3, then you should first know about browser prefix when using most css3 properties. But since you are starting out, I advice you focus on html4 and css2. There are certain workarounds in getting html5 elements to be rendered well across browsers which you may not need to bother yourself with for now.
Re: Having Problems With Css And Doctype Declaration by veightar: 12:46pm On Jul 27, 2013
You should likewise compare your header code with what @graphicplus has posted. If your css is not working at all, then you might be missing a closing tag.

For example if you declare an html4 doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
you should check the closing ">. If it's not there, that might affect your other heading tags.
1 Reply

Am Having Problems With My Adsense Approval • Having Problems With Seo? Come In Lets Talk. • Having Problems With Graphcard? • 2 • 3 • 4

Learn How To Check If A Domain Name Is Banned From Adsense - See More At: Http:/ • MUST READ: Owning A Website • Need D Best Website Proposal