The issue I'm facing with my CSS is that the Doctype is causing some styles to

Hey there! I've been pondering the use of !DOCTYPE html lately.

I recently put together a basic webpage that looked great on most browsers except for IE. After doing some digging, it was recommended to me to use !DOCTYPE html. However, this ended up messing with some of my CSS, but not all of it.

I delved into the issue and found some advice about potential misspellings between my id tags and .css # tags.

Despite the hiccup, a small piece of JavaScript is still functioning properly for me. My two divs are working smoothly, allowing users to scroll while the submit button remains visible.

Unfortunately, I'm losing my CSS styling for the table and home button. It's all tied up in some old-school ASP code, which may be contributing to the problem since I'm more accustomed to using ASP.NET.

<%
    Set Cn = Server.CreateObject("ADODB.Connection")
    Cn.Open CnString
    ' Build Sql.
    Sql = "SELECT [USER_CODE],[WINDOWS_ID], [FIRST_NAME], [LAST_NAME], [ACTIVE_IND] FROM      FSUSER ORDER BY [LAST_NAME]"
    ' Open recordset.
    Set Rs = Cn.Execute(Sql)
    If Not Rs.Eof Then arrayActiveUsers = Rs.GetRows()
    Rs.Close
    Set Rs = Nothing
    Response.Write "<form action='main1.asp' method='post'>"
    Response.Write "<div id=""top"">"
    Response.Write "<button name=""regions1"" type=""submit"" value="&regions&" >Save_"&regions&"</button>"
    Response.Write "<a href=""default.asp"" id=""home"" onclick=""return confirm('Have you saved your changes before leaving this page?');"" >Home</a>"
        Response.Write "</div>"
    Response.Write "<div id=""bottom"">"
    Response.Write "<table id=""table1"">"
    Response.Write "<tr>"
    Response.Write "<td>User Code</td>"
    Response.Write "<td>Windows ID</td>"
    Response.Write "<td>First Name</td>"
    Response Write "<td> Last Name</td>"
    Response.Write "<td> Status</td>"
    Response.Write "<td> ACTIVATE</td>"
    Response.Write "<td> DE-ACTIVATE</td>"
    Response.Write "</tr>"

    Response.Write "<tr>"
For j = 0 To UBound(arrayActiveUsers,2)
if arrayActiveUsers(4,j) = 1 then
        Response.Write "<td>" & arrayActiveUsers(0,j) & "</td>" 
        Response.Write "<td>" & arrayActiveUsers(1,j) & "</td>"
        Response.Write "<td>" & arrayActiveUsers(2,j) & "</td> "
        Response.Write "<td>" & arrayActiveUsers(3,j) & "</td>"
        Response.Write "<td ><font color=""green"">Active</font></td>" 
        Response.Write "<td></td>" 
        Response.Write "<td><input type=""checkbox"" name=""active"" value="  & arrayActiveUsers(0,j) &" /></td>"

Response.Write "</tr>"  
else    
        Response.Write "<td>" & arrayActiveUsers(0,j) & "</td>"
        Response.Write "<td>" & arrayActiveUsers(1,j) & "</td>" 
        Response.Write "<td>" & arrayActiveUsers(2,j) & "</td> " 
        Response.Write "<td>" & arrayActiveUsers(3,j) & "</td>"
        Response.Write "<td><font color=""red"">Not Active</font></td>" 
        Response.Write "</td>" & "<td><input type=""checkbox"" name=""de- active"" value=" & arrayActiveUsers(0,j) &"  /></td>" 
        Response.Write "<td></td>"

        Response.Write "</tr>"
end if
next
Response.Write "</table>"
Response.Write "</div>"
Response.Write "</form>"
 Cn.Close
 Set Cn = Nothing
 %>

Here is the HTML header:

<!DOCTYPE html>
<HTML>
<HEAD>
  <link rel="stylesheet" type="text/css" href="main1.css">
<TITLE> Main </TITLE>
   <script type="text/javascript">
            function greeting(){
                alert("Have you committed all your data?")
            }
      </script>
</HEAD>
<BODY>

And this is the CSS being used:

#top{
top:0;
position:fixed;
background: white;
}

#bottom{
margin-top:40px;
}

#home{
display: inline;
width: 115px;
height: 24px;
background: #E6E6E6;
padding: 0px;
text-align: center; 
border-width:2px;
border-style:ridge; 
border-color: gray;
color: black;    
}

#table1{
padding:3;
border:groove,2px,#f0f0f0;
background-color:a0a0a0;

}

If anyone spots any glaring errors that I missed, please let me know. I understand that the CSS might appear differently on IE compared to other browsers, but if we can get it working, maybe I can create separate style sheets for IE and everything else.

I should mention that I've tried multiple doctypes with the same result.

Answer №1

It's uncertain if this is the underlying cause of the issue, but <!DOCTYPE html> appears to be specific to HTML5 and it may not be what you're aiming for.

If you want to ensure better compatibility without using frames in an HTML4 environment, consider using:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

Answer №2

To provide more assistance, it would be helpful if you could create a jsfiddle with your final HTML so we can test it. The issue may be caused by poorly written CSS or a problematic HTML tag that has not been properly closed.

It's important to note that the DOCTYPE declaration is always required. Without it, browsers may render the site differently and cause inconsistencies in how styles are applied, especially in older versions of IE. This could result in your site looking fine in one browser but terrible in others. Fixing the styles may require rewriting all of your CSS if it was originally created using bad standards, similar to building a house on unstable ground.

Answer №3

Dealing with a similar problem, I decided to take the following steps:

  1. After reviewing all the pages on the site, I opted to create a single include file (doctype.asp) instead of declaring the DOCTYPE for each page.
  2. The contents of this file are as follows:

    <!DOCTYPE html >
    <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8         lt-ie7" xmlns:fb="http://ogp.me/ns/fb#"> <![endif]-->
    <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" xmlns:fb="http://ogp.me/ns/fb#"> <![endif]-->
    <!--[if IE 8]>         <html class="no-js lt-ie9" xmlns:fb="http://ogp.me/ns/fb#"> <![endif]-->
    <!--[if gt IE 8] ><!--> <html class="no-js" xmlns:fb="http://ogp.me/ns/fb#"> <!--<![endif]-->
    
  3. By ensuring that all pages use the same DOCTYPE declaration, I was able to resolve any CSS issues across the entire site.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Evaluating QUnit Test Cases

How do you write a test method in QUnit for validating functions developed for a form? For example, let's consider a form where the name field should not be left blank. If the validation function looks like this: function validNameCheck(form) { if ...

Manipulate the lines in an HTML map and showcase the distinctions between them

I've been searching through various inquiries on this particular subject, but none have provided me with a satisfactory response. I have created a map where I've set up 4 axes using the following code: function axis() { var bounds = ...

The justify-content property aligns single-line text horizontally, but its alignment may not be consistent when the text expands over

Seeking a deeper understanding of flexbox alignment, I decided to experiment with aligning content using only flexbox properties. One puzzling observation is how "justify-content" centers items with single lines of text (flex-item-1 and flex-item-5), but n ...

Is there a way to insert a colored square into a <button> tag rather than text?

Looking for help with the following HTML: <button name="darkBlue" onclick="setThemeColor(this.name)">Blue</button> <button name="black" onclick="setThemeColor(this.name)">Black</button> I'm interested in replacing the text on ...

What is the best way to manipulate the canvas "camera" in HTML?

I am currently developing a 3D game that involves navigating through skyboxes. My goal is to have the camera respond to user input, specifically detecting key presses (using WASD controls) to move the camera accordingly. Do you have any suggestions on how ...

Associate information with HTML elements

I've come across this question multiple times, but the solutions are mostly focused on HTML5. My DOCTYPE declaration is: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> I'm looking t ...

javascript basic image carousel

How can I modify my slider so that "slide 1" appears after "slide 3" without needing to use the return or previous button each time? I'm not very well-versed in javascript, so I thought I'd reach out for some assistance ...

Having difficulty locating the identification number of an item within the HTML coding

I'm currently trying to locate the ID of the "proceed to checkout" button for a bot that I am developing for my mother on the Best Buy website. However, it seems like the button's ID is hidden and I'm unable to determine how to uncover it. A ...

"Error: The function $(...).autocomplete is not recognized" in conjunction with Oracle Apex

Currently experiencing some frustration trying to solve the issue at hand. The Uncaught TypeError: $(...).autocomplete is not a function error keeps popping up and I have exhausted all resources on Stack Overflow in an attempt to fix it. This problem is oc ...

Issues with interpreting PHP within HTML documents

I'm having trouble using PHP on my HTML page. I've added AddType application/x-httpd-php .html to the .htaccess file as recommended, but when I try to access the page in a browser, a dialog box pops up asking if I want to save the file or open it ...

Form containing unchecked checkbox

I am trying to send a false value via post for a checkbox that is not checked by default. Here is how my checkbox is defined: <label><input type="checkbox" id="rez" name="rezerwowanie" value="false" />Rezerwowanie</label> After submitti ...

Tips for repairing damaged HTML in React employ are:- Identify the issues

I've encountered a situation where I have HTML stored as a string. After subsetting the code, I end up with something like this: <div>loremlalal..<p>dsdM</p> - that's all How can I efficiently parse this HTML to get the correct ...

Is there a way to ensure that the div of my template spans 100% in width and height?

I'm attempting to make my div 100% in size but I am having trouble achieving it. Here is my code: <template> <div> <Navbar/> <Calendar/> </div> </template> <script setup> import Calendar from &apos ...

Utilizing partials in EJS for efficient HTML tag insertion

(1)home.ejs without using partials https://i.stack.imgur.com/3ozQQ.png (2)the output includes html tag, head tag and body tag https://i.stack.imgur.com/1o9jy.png (3)when utilizing header.ejs as a partial in home.ejs including opening html and body ta ...

Lately, I've been working on a practice website I'm developing, and I'm facing some issues with my hyperlinks

Get the omisphere download I created this hyperlink because my previous attempts didn't work, but unfortunately, this one still isn't functioning properly. Is it possible that the issue is with my CSS? ...

Styling text on a HTML webpage

Is there a way to center text in the caption and add a link on the far-right of the caption? Let me know if this is possible. The format for the caption should be: Centered Text Right-justified link ...

Differences in <img> sizing behavior between Chrome and Firefox

Objective: Develop a scrollable image-gallery web component with layouting that functions without script intervention. Specifications: The size of the web component must be fully responsive and/or adjustable. The top main area of the widget is the galle ...

Problem with the menu button overflowing

I'm exploring the process of designing burger menus for the mobile version of my site. I've successfully created a basic burger menu with some JavaScript assistance, but I encountered an overflow issue. The burger menu functions properly, but the ...

Tips for ensuring Marketo forms are responsive when integrated into a WordPress website

We are currently using Wordpress for our responsive website. Within the site, we have integrated Marketo forms (a marketing automation system) with custom CSS for styling. The issue we are facing is that while the forms appear fine on desktops, they cause ...

Expanding content to cover the entire width using CSS Bootstrap 5

As a newcomer to Bootstrap, I am working on customizing an existing Bootstrap example. My objective is to expand the width of the div tag (with id "inner") to fill the entire screen. I have experimented with various approaches, such as resetting the margi ...