id Selector

  • Styles a single unique element
  • Utilises the id attribute of an element
  • Defined with a # followed by the value assigned to the id attribute

 

<!DOCTYPE html>
<html>
	<head>
		<meta></meta>
		<link></link>
		<title>Document Title</title>
		<style>
			#topHeading { color:#00f; }
			#makeRed { color: #F00; }
		</style>
	</head>
	<body>
		<h1 id="topHeading">A very simple page</h1>
		<p>A line of text.<p>
		<p>A line of text.<p>
		<p id="makeRed">A line of text.<p>
		<p>A line of text.<p>
		<p>A line of text.<p>
	</body>
</html>

Save & refresh browser:

A very simple page

A line of text.

 

A line of text.

 

A line of text.

 

A line of text.

 

A line of text.

Leave a Reply