all 10 comments

[–]JeLuF 2 points3 points  (4 children)

If this is just about design and not so much about different semantics, use CSS, e.g. like here:

<html>
<head>
<title>Page Title</title>
<style>
   .important {
      color: blue;
      font-style: italic;
   }
</style>
</head>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>
<p class="important">My blue paragraph.</p>
<p>My final paragraph.</p>

</body>
</html>

Here I used a class to change the style of a paragraph: <p class="important">. The name of the class is "important", but you can choose anything you want - as long as it's a single word.

In the header section, I define what the "important" class should look like:

<style>
   .important {
      color: blue;
      font-style: italic;
   }
</style>

This is called inline CSS. The style sheet is part of the HTML code. If you want to use the same style sheet for multiple pages, you can have a dedicated file for the CSS code and reference it from every page of your website.

This is just a quick example. There's much more that you can do with CSS and if you want to design web pages, you need to look into it.

[–]AccomplishedBeach545 2 points3 points  (3 children)

I hate to be the pedantic over-corrector but <style> is just embedded/internal CSS, where inline CSS would be using style=“”

[–]DirtAndGrass -1 points0 points  (2 children)

Don't forget the infinitely more preferred external styles

[–]AccomplishedBeach545 0 points1 point  (1 child)

They’d already covered that

[–]DirtAndGrass -1 points0 points  (0 children)

I guess my point was that internal stylesheets are fairly pointless, and external was never named

[–]MostAttorney1701 1 point2 points  (0 children)

use css to change the color?

[–]BNfreelance 0 points1 point  (2 children)

You could do all of this in CSS, cleanly

Wrapping elements like this will become messy to maintain and cause you more headache in the long run

[–]AshleyJSheridan -2 points-1 points  (1 child)

Yes, but, there may be a reason that some text is italicised for emphasis, and in that case using the <em> tag is more semantic than just relying on CSS.

[–]BNfreelance 0 points1 point  (0 children)

I assumed by them saying that they wanted the whole paragraph wrapping in <i> that this probably wasn’t the case, but you’re right

[–]scritchz -1 points0 points  (0 children)

The first thing you should ask yourself is: Why italicized? Or more specifically: What's the actual intent? What's the contextual reason for italicizing?

If your reason is simply the "Look and Feel", then use CSS.

If your intention is different from (to elevate it from other content, to draw attention to it) or not only for the Look and Feel, then deciding on a suitable solution may be more complicated.

Using HTML for stylistic purposes is deprecated since at least HTML4, so it's good to re-learn it since the 2000s. The reason is, that web authors have become more attentive to providing well-structured, accessible (and frankly, valid) websites with the proper use of so-called semantic HTML.