Tell us what’s happening:
Hey all,
I am struggling to get this media query working for this challenge. What I have noticed is #small-screen id indicator that I have defined inside the @media is not highlighted in the same burgundy color as the other element, id and class selectors throughout my CSS stylesheet. Bellow is my code, any and all assistance is greatly appreciated.
Note: When I open this in my browser (google chrome) all of the media query CSS changes work as intended.
Your code so far
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>technical document</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="technical-document.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.3/font/bootstrap-icons.css">
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<main>
<div class=" dropdown" id="small-screen" >
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-arrow-down-square"></i>
</a>
<ul class="dropdown-menu">
<li class="dropdown-link">
<a class="link" href="#Introduction">Introduction</a>
</li>
<li class="dropdown-link">
<a class="link" href="#What_you_should_know">What you should know</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Javascript_and_java">Javascript and java</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Hello_world">Hello world</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Variables">Variables</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Declaring_variables">Declaring variables</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Variable_scope">Variable scope</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Global_variables">Global variables</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Constants">Constants</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Data_types">Data types</a>
</li>
<li class="dropdown-link">
<a class="link" href="#if_else_statement">if else statement</a>
</li>
<li class="dropdown-link">
<a class="link" href="#While_statement">While statement</a>
</li>
<li class="dropdown-link">
<a class="link" href="#Reference">Reference</a>
</li>
</ul>
</div>
<nav id="navbar" class="large_screen">
<header>Navigation Tabs</header>
<div class="navbar_container">
<a class="nav-link" href="#Introduction">Introduction</a>
<a class="nav-link" href="#What_you_should_know">What you should know</a>
<a class="nav-link" href="#Javascript_and_java">Javascript and java</a>
<a class="nav-link" href="#Hello_world">Hello world</a>
<a class="nav-link" href="#Variables">Variables</a>
<a class="nav-link" href="#Declaring_variables">Declaring variables</a>
<a class="nav-link" href="#Variable_scope">Variable scope</a>
</div>
<div class="navbar_container">
<a class="nav-link" href="#Global_variables">Global variables</a>
<a class="nav-link" href="#Constants">Constants</a>
<a class="nav-link" href="#Data_types">Data types</a>
<a class="nav-link" href="#if_else_statement">if else statement</a>
<a class="nav-link" href="#While_statement">While statement</a>
<a class="nav-link" href="#Reference">Reference</a>
</div>
</nav>
<h1>JavaScript Documentation</h1>
<main id="main-doc">
<section class="main-section" id="Introduction">
<header>Introduction</header>
<div class="html-items">
<p>
JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight
language. Inside a host environment (for example, a web browser), JavaScript can be connected to the
objects of its environment to provide programmatic control over them.
JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of
language elements such as operators, control structures, and statements. Core JavaScript can be
extended for a variety of purposes by supplementing it with additional objects; for example:
</p>
</div>
<ul>
<li>
Client-side JavaScript extends the core language by supplying objects to control a browser and its
Document Object Model (DOM). For example, client-side extensions allow an application to place
elements on an HTML form and respond to user events such as mouse clicks, form input, and page
navigation.
</li>
<li>
Server-side JavaScript extends the core language by supplying objects relevant to running JavaScript
on a server. For example, server-side extensions allow an application to communicate with a
database, provide continuity of information from one invocation to another of the application, or
perform file manipulations on a server.
</li>
</ul>
<p>HTML is the basics of creating and bringing to life your vision in your mind to an interactive website or
application</p>
<a href=""></a>
</section>
<section class="main-section" id="What_you_should_know">
<header>What you should know</header>
<div class="html-items">
<p>
This guide assumes you have the following basic background:
</p>
</div>
<ul>
<li>
A general understanding of the Internet and the World Wide Web (WWW).
</li>
<li>
Good working knowledge of HyperText Markup Language (HTML).
</li>
<li>
Some programming experience. If you are new to programming, try one of the tutorials linked on the
main page about JavaScript.
</li>
</ul>
<p>HTML is the basics of creating and bringing to life your vision in your mind to an interactive website or
application</p>
<a href=""></a>
</section>
<section class="main-section" id="Javascript_and_java">
<header>Javascript and java</header>
<div class="html-items">
<p>
JavaScript and Java are similar in some ways but fundamentally different in some others. The
JavaScript language resembles Java but does not have Java's static typing and strong type checking.
JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs
which was the reason why it was renamed from LiveScript to JavaScript.
</p>
<p>
In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a
runtime system based on a small number of data types representing numeric, Boolean, and string
values. JavaScript has a prototype-based object model instead of the more common class-based object
model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary
for individual objects. JavaScript also supports functions without any special declarative
requirements. Functions can be properties of objects, executing as loosely typed methods.
</p>
<p>
JavaScript is a very free-form language compared to Java. You do not have to declare all variables,
classes, and methods. You do not have to be concerned with whether methods are public, private, or
protected, and you do not have to implement interfaces. Variables, parameters, and function return
types are not explicitly typed.
</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="Hello_world">
<header>Hello world</header>
<div class="html-items">
<p>
To get started with writing JavaScript, open the Scratchpad and write your first "Hello world"
JavaScript code:
<code>function greetMe(yourName) { alert("Hello " + yourName); }</code>
<code>("World");</code>
<code>Select the code in the pad and hit Ctrl+R to watch it unfold in your browser!</code>
</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="Variables">
<header>Variables</header>
<div class="html-items">
<p>
You use variables as symbolic names for values in your application. The names of variables, called
identifiers, conform to certain rules.
A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent
characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the
characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).
You can use ISO 8859-1 or Unicode letters such as å and ü in identifiers. You can also use the
Unicode escape sequences as characters in identifiers. Some examples of legal names are Number_hits,
temp99, and _name.</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="Declaring_variables">
<header id="Declaring_variables">Declaring variables</header>
<div class="html-items">
<p>
You can declare a variable in three ways:
With the keyword var. For example,
<code>var x = 42.</code>
This syntax can be used to declare both local and global variables.
By simply assigning it a value. For example,
<code>x = 42.</code>
This always declares a global variable. It generates a strict JavaScript warning. You shouldn't use
this variant.
With the keyword let. For example,
<code>let y = 13.</code>
This syntax can be used to declare a block scope local variable. See Variable scope below.
</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="Variable_scope">
<header>Variable scope</header>
<div class="html-items">
<p>
When you declare a variable outside of any function, it is called a global variable, because it is
available to any other code in the current document. When you declare a variable within a function,
it is called a local variable, because it is available only within that function.
JavaScript before ECMAScript 2015 does not have block statement scope; rather, a variable declared
within a block is local to the function (or global scope) that the block resides within. For example
the following code will log 5, because the scope of x is the function (or global context) within
which x is declared, not the block, which in this case is an if statement.
<code>if (true) { var x = 5; } console.log(x); // 5</code>
This behavior changes, when using the let declaration introduced in ECMAScript 2015.
<code>if (true) { let y = 5; } console.log(y); // ReferenceError: y is
not defined</code>
</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="Global_variables">
<header>Global variables</header>
<div class="html-items">
<p>
Global variables are in fact properties of the global object. In web pages the global object is
window, so you can set and access global variables using the window.variable syntax.
Consequently, you can access global variables declared in one window or frame from another window or
frame by specifying the window or frame name. For example, if a variable called phoneNumber is
declared in a document, you can refer to this variable from an iframe as parent.phoneNumber.</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="Constants">
<header>Constants</header>
<div class="html-items">
<p>
You can create a read-only, named constant with the const keyword. The syntax of a constant
identifier is the same as for a variable identifier: it must start with a letter, underscore or
dollar sign and can contain alphabetic, numeric, or underscore characters.
<code>const PI = 3.14;</code>
A constant cannot change value through assignment or be re-declared while the script is running. It
has to be initialized to a value.
The scope rules for constants are the same as those for let block scope variables. If the const
keyword is omitted, the identifier is assumed to represent a variable.
You cannot declare a constant with the same name as a function or variable in the same scope. For
example:
<code>// THIS WILL CAUSE AN ERROR function f() {}; const f = 5; // THIS
WILL CAUSE AN ERROR ALSO function f() { const g = 5; var g;
//statements }</code>
However, object attributes are not protected, so the following statement is executed without
problems.
<code>const MY_OBJECT = {"key": "value"}; MY_OBJECT.key =
"otherValue";</code>
</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="Data_types">
<header>Data types</header>
<div class="html-items">
<p>
<ul>The latest ECMAScript standard defines seven data types:
<ul>Data types that are primitives:</ul>
<li>Boolean. true and false.</li>
<li>null. A special keyword denoting a null value. Because JavaScript is case-sensitive, null is not
the
same as Null, NULL, or any other variant.</li>
<li>undefined. A top-level property whose value is undefined.</li>
<li>Number. 42 or 3.14159.</li>
<li>tring. "Howdy"</li>S
<li>Symbol (new in ECMAScript 2015). A data type whose instances are unique and immutable.
and Object</li>
<p>Although these data types are a relatively small amount, they enable you to perform useful
functions
with your applications. Objects and functions are the other fundamental elements in the
language.
You can think of objects as named containers for values, and functions as procedures that your
application can perform.</p>
</ul>
</p>
</div>
<a href=""></a>
</section>
<section class="main-section" id="if_else_statement">
<header>if else statement</header>
<div class="html-items">
<p>
Use the if statement to execute a statement if a logical condition is true. Use the optional else
clause to execute a statement if the condition is false. An if statement looks as follows:
</p>
<code>if (condition) { statement_1; } else { statement_2; }</code>
<p>
condition can be any expression that evaluates to true or false. See Boolean for an explanation of
what evaluates to true and false. If condition evaluates to true, statement_1 is executed;
otherwise, statement_2 is executed. statement_1 and statement_2 can be any statement, including
further nested if statements.
</p>
<p>
You may also compound the statements using else if to have multiple conditions tested in sequence,
as follows:
</p>
<code>if (condition_1) { statement_1; } else if (condition_2) {
statement_2; } else if (condition_n) { statement_n; } else {
statement_last; }</code>
<p>In the case of multiple conditions only the first logical condition which evaluates to true will be
executed. To execute multiple statements, group them within a block statement ({ ... }) . In
general, it's good practice to always use block statements, especially when nesting if statements:
</p>
<code>if (condition) { statement_1_runs_if_condition_is_true;
statement_2_runs_if_condition_is_true; } else {
statement_3_runs_if_condition_is_false;
statement_4_runs_if_condition_is_false; }</code>
<p>
It is advisable to not use simple assignments in a conditional expression, because the assignment
can be confused with equality when glancing over the code. For example, do not use the following
code:
</p>
<code>if (x = y) { /* statements here */ }</code>
<p>
If you need to use an assignment in a conditional expression, a common practice is to put additional
parentheses around the assignment. For example:
</p>
<code>if ((x = y)) { /* statements here */ }</code>
</div>
<a href=""></a>
</section>
<section class="main-section" id="While_statement">
<header>While statement</header>
<p class="html-items">
<p>A while statement executes its statements as long as a specified condition evaluates to true. A while
statement looks as follows:</p>
<code>while (condition) statement</code>
<p>If the condition becomes false, statement within the loop stops executing and control passes to the
statement following the loop.
</p>
<p>The condition test occurs before statement in the loop is executed. If the condition returns true,
statement is executed and the condition is tested again. If the condition returns false, execution stops
and control is passed to the statement following while.
</p>
<p>To execute multiple statements, use a block statement ({ ... }) to group those statements.
</p>
<p>Example:
The following while loop iterates as long as n is less than three:
</p>
<code>var n = 0; var x = 0; while (n < 3) { n++; x +=n; } </code>
<ul>With each iteration, the loop increments n and adds that
value to x. Therefore, x and n take on the following values: </ul>
<li>After the first pass: n=1 and x=1 </li>
<li>After the second pass: n=2 and x=3 </li>
<li>After the third pass: n=3 and x=6 </li>
<p>After completing the third pass, the
condition n < 3 is no longer true, so the loop terminates. </p>
<a href=""></a>
</section>
<section class="main-section" id="Reference">
<header>Reference</header>
<li>All the documentation in this page is taken from <a
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide">MDN</a></li>
</section>
</main>
<script src="" async defer></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
body {
min-width: 290px;
color: #4d4e53;
font-family: 'Open Sans', Arial, sans-serif;
line-height: 1.5;
margin: 0 25px 0 25px;
}
.dropdown{
text-align: end;
}
h1{
display: block;
margin: auto;
text-align: center;
}
.dropdown{
background-color: rgb(77, 152, 93);
width: auto;
height: auto;
}
nav {
display: block;
}
#navbar {
max-height: 150px;
z-index: 3;
display: none;
position: fixed;
flex-direction: column;
background-color: rgb(77, 152, 93);
flex-basis: 0;
flex-grow: 1;
flex-shrink: 1;
flex-wrap: nowrap;
justify-content: space-around;
top: 0px;
left: 0px;
width: auto;
height: auto;
border-right: solid;
border-color: rgba(0, 95, 21, 0.4);
}
.navbar_container{
display: flex;
}
#navbar a {
margin: 10px;
padding: 10px 30px;
color: black;
text-decoration: none;
cursor: pointer;
}
#main-doc {
position: absolute;
margin: auto;
padding: 20px;
margin-bottom: 110px;
}
section {
display: block;
margin: auto;
}
header {
color: black;
margin: 10px;
padding: 4px;
font-size: 1.8em;
font-weight: thin;
border-bottom: solid ;
border-color: rgba(0, 95, 21, 0.4);
background-color: rgba(201, 202, 201, 0.4);
}
@media (min-width: 800px) {
#small-screen{
display: none;
}
main{
margin-top: 200px;
}
#navbar{
display: flex;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Challenge: Technical Documentation Page - Build a Technical Documentation Page
Link to the challenge: