.rel attribute in <img> element

The following question relates to the code below.

**<head>**
**  <link href='./style.css' *rel="stylesheet"* />**
**</head>**

Compared to the next code, the italicized attribute is missing.

<head> <link href='./style.css' /> </head>

Is this still good style writing or should one always include the ‘rel’ attribute for readability and SEO ?

The rel attribute describes the relationship that the imported resource has to the document. From the MIME type, alone, the browser or user agent can infer the style sheet relationship, but explicitly stating it is part of a well formed document.

Aside

Consistent writing/authoring style is a most sought after aspect, and where quote marks are concerned, double quotes are more typical in static HTML. We never mix our quotes, as the above example does.

<link rel="stylesheet" href="./style.css">

As for the ‘space-slash’, that is extraneous and unnecessary in HTML on the basis that most pages are served as text. We only need the ‘slash’ (and not the space) when writing XML conformant markup that is served as, ‘application/xml’, not as ‘text/html’, the default and defacto MIME type for our purposes.

Bottom line: double quotes on attributes, and drop the space-slash.

1 Like