Looking for advice on how to clean my mess up

I’m pretty new to HTML and CSS, and I’m currently working on an internal webpage for work. I’ve got almost all functionality done so I’ve started going back and finding things to clean up in the code and ways to make the page look a little nicer. I’m hoping maybe I can get some tips on one particular page. It was the first one I did and I’ve gotten a lot of backlash on how I handled some things. Here’s a short explanation of the page, take note that this is also an asp.net project: At the top of the page is the title, followed directly by a video that is put there by using a content management system and asp.net code. Below that there is a large space where there are actually 4 overlapping text blocks, but only one is visible when the page loads. Below the text are 4 buttons. Each button makes the current text become invisible and the associated text become visible. I’ve had some people tell me to try to do this all in Javascript, but this was after I had almost the whole page done, and to be honest, I’m about as experience with Javascript as I am with HTML and CSS. One major question I have is regarding the overlapping text. Everyone seems to think it’s bad for me to use position:absolute in my CSS, but I can’t figure out any other way to put the text in the same place. If anyone can look at this page and let me know a better way to do it or a good way to clean it all up, I’m open to all suggestions and constructive criticism! I’m just here to learn!

Someone previously had mentioned since I’m using asp.net and in visual studio I see code that you guys can’t easily use, I should run the page and then grab the source from there, so that is what I have done below. Because of that you will see the layout page joined with the actual page I’m worried about, so there is some code for the menu at the top. I have left off the code at the bottom for the RSS Feeds.

HTML:

<!DOCTYPE html>
<html>

<head>
    <link href="\css/LayoutStyleSheet.css" rel="stylesheet"/>
    <link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OurCompany - My ASP.NET Application</title>
    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.css" />

</head>
<body id="layoutBody" style=" font-family: 'Oswald', sans-serif;">

<nav class="navbar navbar-inverse navbar-static-top marginBottom-0" role="navigation">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <div id="spacerDiv">
            <a class="navbar-left"><img id="logo" src="/Images/SC2_MyLink_Logo.png" alt="Browser does not support image."/></a>
        </div>
    </div>
    <div class="collapse navbar-collapse" id="navbar-collapse-1">
        <ul id="navigationbar" class="nav navbar-nav">
            <li id="homebutton" class="dropdown"><a href="#"><a href="/">Home</a></a></li>
            <li class="menubuttons dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Our Company<b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li><a href="/OurCompany">Our History</a></li>
                    <li><a href="/OurCompany/Facilities">Facilities</a></li>
                </ul>
            </li>
            <li class="menubuttons dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Employee Services<b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li class="dropdown dropdown-submenu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Forms</a>
                        <ul class="dropdown-menu">
                            <li><a href="/FormsHandlers/HRForms">HR Forms</a></li>
                            <li><a href="/FormsHandlers/CorporateForms">Corporate Forms</a></li>
                            <li><a href="/FormsHandlers/EmployeeBenefitsForms">Employee Benefits</a></li>
                            <li><a href="/FormsHandlers/AccidentForms">Accident Forms</a></li>
                            <li><a href="/FormsHandlers/PayrollForms">Payroll Forms</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Pay Stubs</a></li>
                    <li><a href="/FormsHandlers/FAQ">FAQ</a></li>
                </ul>
            </li>
            <li class=" menubuttons dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Support Services<b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li><a href="#">ISS Support</a></li>
                    <li><a href="#">Purchase Requests</a></li>
                    <li><a href="#">Maint. Support</a></li>
                </ul>
            </li>
        </ul>
        <form id="searchbar" method="get">
            <input type="text" id="search" placeholder="Search..." maxlength="50" autocomplete="off" onmousedown="active();" onblur="inactive();">
            <input type="submit" id="searchbutton" value="Go!"/>
        </form>
    </div><!-- /.navbar-collapse -->
</nav>

<!DOCTYPE Html>
<link href="\css/AboutUsStyleSheet.css" rel="stylesheet" />



<div align="center">
    <div>
        <h1>About Us</h1>
    </div>
    <div class="promovid">
            <video width="850" height="700" autoplay>
                <source src="//videos.contentful.com/6yl0vo95lmum/6iPFqBAYZU6o6C4SQA0SuQ/a591a02b365a5d30cacd23b2909d6747/SC2_Finished_Promo.mp4" type="video/mp4"/>
                Your browser does not support the video tag.
            </video>
    </div>

    <div class="text">
        <div id="missionstatement"></div>
        <div id="missionstatement2">
            <div class="vision">
                <h3>Vision</h3>
            </div>
            <div class="missionP1">
                <p>
                    To lead the supply chain services industry through the delivery of high quality service and manufacturing solutions, <br/>while maximizing strategic value to our customers by exceeding expectations and facilitating growth.
                </p>
            </div>
            <div class="mission">
                <h3>Mission</h3>
            </div>
            <div class="missionP2 ">
                <p>
                    SC2, a 100% employee‐owned company, represents a promise to deliver high quality, on time, cost‐effective supply‐chain<br/> Solutions—offering customized services from a team that is committed to excellence.
                </p>
            </div>
        </div>
        <div id="esop">
            <div class="esoptitle">
                <h3>What is ESOP?</h3>
            </div>
            <div class="esopP1">
                <p>
                    Employee Stock Ownership Plan (ESOP) is a benefit program that provides company stock to its employees. <br/>

                    Several features make ESOPs unique:<br/>
                    <li>
                        An ESOP is required by law to invest primarily in the securities of the sponsoring employer.<br/>
                    </li>
                    <li>
                        An ESOP is unique among qualified employee benefit plans in its ability to borrow money.<br/>
                    </li>
                    <li>
                        As a result, "leveraged ESOPs" may be used as a value-added advantage to corporate finance.<br/>
                    </li>
                    <li>
                        All full-time employees participate, reaping the benefits of business success.<br/>
                    </li>
                </p>
            </div>
            <div class="esop1">
                <h3>Employee Ownership Makes a Difference</h3>
            </div>
            <div class="esopP2">
                <p>
                    There are approximately 11,000 employee-owned companies in the United States; only about 1,000 of those are 100% owned by employees.<br/><br/>

                    At SC2, the success and growth of our employee-owners is directly related to the success and growth of our company. Everyone at SC2 has a vested interest in the success of the company which prodcues a competitive advantage.<br/><br/>

                    Business ownership fills our employees with pride. Our talented and experienced employee owners take great pride in servicing our customers. Employees are rewarded through increased compensation and rising stock valuations.<br/><br/>

                    The commitment and dedication associated with employee ownersehip has continued to be the recipe for our Success.<br/>
                </p>
            </div>
        </div>
        <div id="sc2difference">
            <div class="sc2title1">
                <h3>The Difference</h3>
            </div>
            <div class="sc2P1">
                <p>
                    At SC2 Supply Chain Services & Solutions we do more than provide a service, we offer customized supply chain solutions which provide unmatched value in our industry. We offer:
                </p>
            </div>
            <div class="sc2title2">
                <h3>Expertise & Technology</h3>
            </div>
            <div class="sc2P2">
                <p>
                    For over 25 years, SC2 has provided supply chain services and solutions to Tier 1 & Tier 2 Manufacturers and OEMs. Throughout this time, we have invested in the technology and the techniques that ensure quality excellence and efficient delivery. SC2 combines our experience and industry leading systems (Warehouse Management System (WMS), Quality Management System (QMS) and Safety Management System (SMS)) with partners like the world’s largest construction equipment manufacturer to maximize total customer satisfaction.
                </p>
            </div>
            <div class="sc2title3">
                <h3>Variety & Flexibility</h3>
            </div>
            <div class="sc2P3">
                <p>Because all companies have unique needs, SC2 provides a one-stop shop for supply chain solutions. From finishing and fabrication to manufacturing support and asset recovery, we work closely with our partners to evaluate services that provide maximum value supply chain solutions.</p>
            </div>
            <div class="sc2title4">
                <h3>Precision & Efficiency</h3>
            </div>
            <div class="sc2P4">
                <p>Every part, every piece, every dollar and every minute counts in this industry. That’s why we’ve spent the last two decades developing and refining our systems to provide precise and efficient solutions for our partners. These superior systems ensure that we are always on time and always the best value.</p>
            </div>
            <div class="sc2title5">
                <h3>Quality & Continuous Improvement</h3>
            </div>
            <div class="sc2P5">
                <p>When you partner with SC2, you team with a company that will ensure quality excellence now and in the future. Our systems ensure real-time visibility of internal and external errors. Through Six Sigma and Lean we can guarantee action, elimination of waste and sustainability. We are not only dedicated to quality excellence today, but are devoted to solutions that will provide you with continued cost savings and maximum value.</p>
            </div>
            <div class="sc2title6">
                <h3>Ownership & Commitment</h3>
            </div>
            <div class="sc2P6">
                <p>Unlike any other in our industry, SC2 is proud to be 100% employee owned. Our partners benefit from a motivated and committed workforce that has a vested interest in achieving excellence. Workforce optimization has proven to be a strategic advantage.</p>
            </div>
        </div>
        <div id="ourhistory">
            <div class="historytitle">
                <h3>Our History</h3>
            </div>
            <div class="historyP">
                <p>
                    In 1983, Superior Blasting &amp; Painting Inc. opened in Tremont,IL. The business grew over the next five years and in 1987 the company became the supplier in world-wide product returns for a local fortune 500 company. In 1988, the employees purchased the company through an ESOP (Employee Stock Ownership Plan). In the early 1990's, we added many new services such as commercial packaging and sub-assembly.
                    The company was renamed Superior Consolidated Industries to reflect the new and diverse service offerings. In 1996, we relocated our headquarters to Peoria while expanding to include in-house services and warehouse management. In 2000, we opened two locations in East Peoria to facilitate growth and improve paint operations. By December 2002, we again changed our company name to SC2 Supply Chaing Services to realign with our updated corporate identity and image.
                    Within the last six years, SC2 has continued to grow in both size and services. In 2004, SC2 acquired NuAir Filter Corporation located in Bloomington/Normal, IL. The addition of NuAir provided many new service offerings such as air filteration, fabrication, kitting, sequencing and in-house maintenance. In the last 3 years, we have added logistics facilities in Mossville and Bartonville, IL. as well as Waco, TX.
                    Today, our thousands of dedicated employee-owners at our 11 facilities have a personal stake in SC2's success as our customers' satisfaction. We combine efforts to achieve the growth, expansion and diversification necessary to define our future. <br/><br/>
                    Our Corporate Operating System is outlined by the following principles: <br/>
                    <ul>
                        <li>Safety First</li>
                        <li>Continuous Improvement</li>
                        <li>Total Customer Satisfaction</li>
                        <li>Achieve Excellence</li>
                    </ul>
                </p>
            </div>
        </div>
    </div>
    <div id="container">
        <br>
        <ul id="nav">
            <li> <a href="#missionstatement">
                <div id="start">
                    <div id="oval"><br/> Mission Statement
                    </div>
                </div></a> </li>
            <li> <a href="#esop">
                <div id="oval"><br/> ESOP
                </div></a> </li>
            <li> <a href="#sc2difference">
                <div id="oval"><br/> SC2 Difference
                </div></a> </li>
            <li> <a href="#ourhistory">
                <div id="oval"><br/> Our History
                </div></a> </li>
        </ul>
        <script>
            function init() {
                document.getElementById('start').click();
            }

            init();
        </script>
        <br style="clear: both">
    </div>

    <p>&nbsp;</p>
</div>



CSS:

h1 {
    color: white;
    padding: 0;
}

.promovid {
    height: 42em;
    width: 100%;
    margin-top: 0%;
    padding-top: 0%;
}

.text {
    position: relative;
    color: white;
    width: 100%;
    height: 35em;
    text-align: left;
    padding: 10px;
}
/*Mission Statement Start*/
.vision {
    position: absolute;
    left: 0;
    right: 0;
    margin: auto;
    margin-left: 12%;
}

.missionP1 {
    position: absolute;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 8%;
    margin-left: 12%;
}

.mission {
    position: absolute;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 15%;
    margin-left: 12%;
}

.missionP2 {
    position: absolute;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 21%;
    margin-left: 12%;
}
/*Mission Statement End*/
/*Our History Start*/
.historytitle {
    position: absolute;
    top: 0%;
    left: 0;
    right: 0;
    margin: auto;
    margin-left: 10%;
}

.historyP {
    position: absolute;
    top: 10%;
    left: 0;
    right: 0;
    margin: auto;
    width: 80%;
}
/*Our History End*/
/*ESOP Start*/
.esoptitle {
    position: absolute;
    top: 0%;
    left: 0;
    right: 0;
    margin: auto;
    margin-left: 11%;
}

.esopP1 {
    position: absolute;
    top: 0%;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 4%;
    margin-left: 11%;
}

.esop1 {
    position: absolute;
    top: 0%;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 16%;
    margin-left: 11%;
}

.esopP2 {
    position: absolute;
    top: 0%;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 22%;
    margin-left: 11%;
}
/*ESOP End*/
/*SC2 Difference Start*/
.sc2title1 {
    position: absolute;
    top: 0%;
    left: 0;
    margin: auto;
    margin-left: 1%;
}

.sc2P1 {
    position: absolute;
    top: 0%;
    left: 0;
    margin: auto;
    width: 45%;
    margin-top: 4%;
    margin-left: 1%;
}

.sc2title2 {
    position: absolute;
    top: 0%;
    left: 0;
    margin: auto;
    margin-top: 10%;
    margin-left: 1%;
}

.sc2P2 {
    position: absolute;
    top: 0%;
    left: 0;
    margin: auto;
    width: 45%;
    margin-top: 15%;
    margin-left: 1%;
}

.sc2title3 {
    position: absolute;
    top: 0%;
    left: 0;
    margin: auto;
    margin-top: 24%;
    margin-left: 1%;
}

.sc2P3 {
    position: absolute;
    top: 0%;
    left: 0;
    margin: auto;
    width: 45%;
    margin-top: 29%;
    margin-left: 1%;
}

.sc2title4 {
    position: absolute;
    top: 0%;
    right: 24.5%;
    margin: auto;
    margin-right: 1%;
}

.sc2P4 {
    position: absolute;
    top: 0%;
    right: 0;
    margin: auto;
    width: 45%;
    margin-top: 4%;
    margin-right: 1%;
}

.sc2title5 {
    position: absolute;
    top: 0%;
    right: 12%;
    margin: auto;
    margin-top: 10%;
    margin-right: 1%;
}

.sc2P5 {
    position: absolute;
    top: 0%;
    right: 0;
    margin: auto;
    width: 45%;
    margin-top: 15%;
    margin-right: 1%;
}

.sc2title6 {
    position: absolute;
    top: 0%;
    right: 20%;
    margin: auto;
    margin-top: 24%;
    margin-right: 1%;
}

.sc2P6 {
    position: absolute;
    top: 0%;
    right: 0;
    margin: auto;
    width: 45%;
    margin-top: 29%;
    margin-right: 1%;
}


/*SC2 Difference End*/

#nav li {
    float: left;
    list-style: none;
    text-align: center;
    width: 18em;
    height: 10em;
    margin-left: 6%;
}

    #nav li a {
        text-decoration: none;
        font-size: 1.2em;
    }

        #nav li a div:hover {
            background-color: lightgrey;
        }

#missionstatement2, #ourhistory, #esop, #sc2difference {
    display: none;
}
#ourhistory:target, #esop:target, #sc2difference:target {
    display: block;
    animation: highlight 3s forwards;
}
#missionstatement {
    position :fixed;
    height:0;
    width:0;
}
#missionstatement:target + #missionstatement2 {
    display: block;
    animation: highlight 3s forwards;
}
#oval {
    width: 240px;
    height: 120px;
    background: #9bb9d4;
    -moz-border-radius: 135px / 75px;
    -webkit-border-radius: 135px / 75px;
    border-radius: 135px / 75px;
    padding: 5px;
    margin: 8px 8px;
    font-size: 1.5em;
}

#start {
    -moz-border-radius: 135px/75px;
    -webkit-border-radius: 135px/75px;
    border-radius: 135px/75px;
    width: 240px;
    height: 120px;
}

#container {
    color: white;
    min-height: 200px;
    padding: 5px;
}

Don’t know if this was a copy and paste error but there is a random <!doctype> and css include inside the page body. If you are including a file into your main template you don’t need to include all the page headers etc as the main template takes care of this.

why specify the font here? put this in the stylesheet. probably also worth putting all the stylesheets together in the header so it’s easy to see the order and what you have, not essential but would be cleaner. Also any overriding css you want to replace bootstrap should be below the bootstrap link. so i’d re-order them,

this is old school. Use css to align things in divs. Same with your video width and height use css as you can make it scale to be responsive rather than fixed width.

Absolute is not the best method for placement if you want your site to be responsive. It might look ok on your screen but odds on it won’t on other screens.

So here’s my issue, when I try to use alignment in CSS, it tells me that “alignment is not a known CSS 3.0 property name”? Is there something else I should be using to align things with CSS? Also, what can I use in place of absolute but still have things overlap? That was my problem and the entire reason I caved and used absolute.

Ethanforbes89, you can use the W3C to find out the syntax for centering things in CSS. Use them to answer all your CSS and HTML questions, in fact. For example, https://www.w3.org/Style/Examples/007/center.en.html

Ah I see, so in this case I needed to use text-align. I was just trying to use alignment. Now I can go through and use CSS on all the other places that I aligned stuff with html.

I’d urge you to get into the habit of validating your code, as your HTML is invalid, and invalid code may not behave as you expect or intend. https://validator.w3.org

That’s correct.

If you’re trying to centre text, then you want to use text-align: center;.

Generally speaking, you woyuld use margins to centre divs and other block level elements.

1 Like

To be fair it is quite tricky to get that sort of “tab” effect any other way, though it’s not something I have tried for a while but I did see this article linked in a recent topic here. And yes, it uses absolute.
The problem being it can’t have a natural height because it’s out the the normal flow.
I was thinking whether it would be possible with relative, but have not given it a go yet.

Can I ask why the code needs to be validated? That sounds like a stupid question, but on the other hand, all the errors that I’m getting don’t seem to be effecting anything. Of course, I’m going through and fixing everything to try to make it as valid as possible, which is helping me learn the right way to do a few things and to clean up the code, but I’m just curious as to why validate?

Well, as I said earlier:

If your code is incorrectly constructed, then browsers may be unable to tell where one element is supposed to end and the next to begin. How they interpret invalid code will vary from browser to browser. They might all get it “right” and display the page according to your intentions, but then again, they may not. You can’t expect your styles to be applied correctly and consistently if the HTML to which you are applying them is invalid.

Ah I see. So it has to do with using different browsers. And I would assume as browsers progress they will make changes based on valid html, so something that works now may not work later. That makes sense. Looks like I’ve got some major clean up to do then.

Browsers do some error correcting of your html, but they don’t all correct the same things. So while something might look correct in your usual browser, another one may interpret it exactly as written and wreck the page
.

As said browsers can do things differently, even with valid code. for example IE won’t include padding on the width of a container whereas FF would. So a 200px with box with 10px padding would be 200px in IE and 220px in FF.
To get around this you would have to add box-sizing:border-box to tell the box to exclude the padding and borders from the width and just show at the width you have specified.

Other useful things off the top of my head is using float:left to position divs next to each other. the parent div should have display:hidden to stop it collapsing and having no height if all child divs are floated.

max-width is very useful for responsive display. You can set a width of say 500px and a max-width of 100% and if the screen is smaller than 500px it will scale the div etc. You can also set a min-width to stop it becoming unreadable etc.

This is the reason for “CSS resets”.

In this case it’s better to set max-width: 500px that way width retains the default value of auto which is naturally responsive and more useful than 100% as you don’t need to account for the box-sizing.

I might be missing something but if using floats then not setting width seems to cause some issues as the child divs don’t fill the space.

Yes, with floats you will want a width. I was thinking of general container elements.

cool. glad i wasn’t missing something. I’m assuming the OP is going to need to get to grips with floating things to layout without resorting to absolute positioning.

Hi uhhm I know I am late but can anyone show me what the website would look like all I’m getting is alot of blank spaces I assume they are where the images sit but I cant make out what is going on here and what the goal of the site is suppose to look like I’d do better when I understand what it’s suppose to look like?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.