Thread: CSS Question
View Single Post
Old 11-12-2020, 12:04 AM   #23
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Quote:
Originally Posted by phossler View Post
I have <p> with text-indent = 2em since the vast majority of the time that's the default for a basic text paragraph.

Sometimes however (usually for a a group specially formatted paragraphs I use <p class="noindent">

I've tried to bracket a group with <div class="noindent"> ... </div> but the class seems to be ignored. If I can't do that, is there another way to 'turn off' indenting for a block of paragraphs?

Spoiler:
@charset "utf-8";
/* Styles for Test_CSS */
p {
text-indent: 2em;
}
.noindent {
text-indent: 0em;
}


and

Spoiler:
<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<head>
<title>Test_CSS</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>

<body>

<h1>Test_CSS</h1>

<p>Some indented text </p>
<p>Some indented text </p>
<p>Some indented text </p>

<div class = "noindent">
<p>Some not indented text </p>
<p>Some not indented text </p>
<p>Some not indented text </p>
</div>

</body>

</html>
Change the following:

.noindent {
text-indent: 0em;
}

to this:

.noindent {
text-indent: 0;
}

When the value is 0, you never add the "em." It should work fine after you delete the "em." You should also change the <p> for the nonindented paragraphs to something like: <p class="noindent"> and don't use the <div> line at the top. It's best to assign a class to each kind of paragraph, etc. One for indents (the common indent is 1.2em, not 2em) and one for nonindents. Then you won't need the <div> lines, which only adds clutter to your file.

Last edited by deback; 11-12-2020 at 12:07 AM.
deback is offline   Reply With Quote