В качестве примера можно привести следующие коды.В каком порядке выполняются коды веб-страницы и как мы можем изменить порядок?
var tst;
tst = document.getElementsByClassName("tst");
tst.style.backgroundColor = "#008000";
tst.style.marginTop = "50px";
tst.innerHTML = "Testing an element.";
body {
\t font-size: 0px;
\t padding: 0px;
\t margin: 0px;
\t width: 100%;
\t overflow-x: hidden;
}
.tst {
\t font-family: Arial;
\t font-size: 20px;
\t color: #FFFFFF;
\t text-align: center;
\t background-color: #FF0000;
\t padding: 10px;
\t margin: 10px auto 0px auto;
\t width: 200px;
\t display: block;
\t overflow: hidden;
}
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<div class="tst"></div>
<script src="./js_style.js"></script>
</body>
<html>
Теперь мой вопрос, в каком порядке браузер будет выполнять эти коды,
как,
1. Browser default
2. External style sheet
3. Internal style sheet (in the head section)
4. Inline style (inside an HTML element)
5. Styles in JavaScript
или в другом порядке? И как мы можем изменить порядок?
Спасибо всем.
Вы не можете изменить порядок. – jcubic
@ jcubic - это право заказа? –
@ Md.DesignMine - ваша идея 'order' неуместна - стили ** применяется **, не _executed_, используя их ** специфичность ** - https://developer.mozilla.org/en-US/docs/ Web/CSS/Specificity ... –