Styled Code Block
Selectors define which HTML elements the CSS rules apply to. Here are the different types of selectors:
-
Type (Element) Selector: Targets an element by its tag name.
p {color: blue;}cssThis targets all
<p>
elements. -
Class Selector: Targets elements by their class attribute.
.example {font-size: 16px;}cssThis targets all elements with the class “example” (e.g.,
<div class="example">
).
const button = document.createElement('button');button.textContent = 'Click me';document.body.appendChild(button);
js
<?php
use Frostybee\Geobee\Calculator;
/* * Calculate the distance from downtown Montreal to Laval. * From: Ville-Marie * postal code area: H3A * Latitude/Longitude: 45.4987, -73.5703 * To: Laval * postal code area: H7T * Latitude/Longitude: 45.55690, -73.7480 */$calculator = new Calculator();$distance = $calculator->calculate( $from_latitude, $from_longitude, $to_latitude, $to_longitude)->getDistance(); // Distance in meters.
php
try { // Outer try block echo "Outer try block <br/>";
try { // Inner try block echo "Inner try block"; throw new RuntimeException("An error occurred in the inner block"); } catch (RuntimeException $e) { // Handle inner exception echo "Caught in inner catch: " . $e->getMessage() . "<br/>"; }
// This code will still run even if inner block throws an exception echo "Continuing in outer try block <br/>";
// Simulate another error throw new Exception("An error occurred in the outer block");
} catch (Exception $e) { // Handle outer exception echo "Caught in outer catch: " . $e->getMessage() . " <br/>";}
php
try { // Outer try block echo "Outer try block <br/>";
try { // Inner try block echo "Inner try block"; throw new RuntimeException("An error occurred in the inner block"); } catch (RuntimeException $e) { // Handle inner exception echo "Caught in inner catch: " . $e->getMessage() . "<br/>"; }
// This code will still run even if inner block throws an exception echo "Continuing in outer try block <br/>";
// Simulate another error throw new Exception("An error occurred in the outer block");
} catch (Exception $e) { // Handle outer exception echo "Caught in outer catch: " . $e->getMessage() . " <br/>";}
php