div id html code example
Example 1: html id
<p id="newid">this is the id</p>
<style>
#newid {
background-color: green;
text-align: center;
}
</style>
Example 2: html div
<div id='number1' class='model'>
<h2>Number 1:</h2>
<h3>Divs</h3>
<p>
Div's are great to split up and shape your website, they can be
modified my css, interact with js and more.
</p>
<!-- Eny regular html code can be put in divs, multiple classes
can be put in divs. Yet divs can only have 1 id. Divs are so useful!-->
</div>
<!-- Hope This Helped! -->
Example 3: html id
<style>
#grepperHeader {
background-color: lightblue;
color: navy;
padding: 40px;
text-align: center;
}
</style>
<h1 id="grepperHeader">grepperHeader</h1>
Example 4: html script id and class
<!--
The script tag's id and class property work just like in any html tag.
Possible use case is to add css styles to your script tag.
Using e.g. 'class="createFunctionality" type="text/javascript"' in a
script is a good practice if you use a editor,
that displays the name of the script when collapsed,
as part of documentation; e.g. Indicate what the script does.
You can also view the source code of the script like this:
-->
<!-- Rememer to add jquery! -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script class="foo" type="text/javascript">
function foobar() {
var a = 1;
}
</script>
<div id="showScript">Show me the script.</div>
<script type="text/javascript">
$('#showScript').click(function(event) {
event.preventDefault();
$("<div>").html($(".foo").text()).appendTo($("body"));
});
</script>
Example 5: html div tag
<div></div>
Example 6: div id css
<p class="haut">
<a href="#haut">Haut de page</a>
</p>